Chapter 16: Problem 8
If a sequential search is performed on an array, and it is known that some items are searched for more frequently than others, how can the contents of the array be reordered to improve the average performance of the search?
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 16: Problem 8
If a sequential search is performed on an array, and it is known that some items are searched for more frequently than others, how can the contents of the array be reordered to improve the average performance of the search?
All the tools & learning materials you need for study success - in one app.
Get started for free
On average, with an array of 20,000 elements, how many comparisons will the sequential search perform? (Assume the items being searched have equal probability of being found at any of the positions in the array.)
One of the algorithms we discussed divides an array into two sublists, with a pivot value between them. It arranges the sublists so that all the values less than the pivot are stored in the left sublist and all the values greater than the pivot are stored in the right sublist. The algorithm recursively sorts the sublists in this same way. When all of the recursive calls have completed, the array is completely sorted. Which algorithm is this?
One algorithm needs 100n basic operations to process an input of size n, and another algorithm needs 25n basic operations to process the same input. Which of the two algorithms is more efficient?
Let \(a[]\) and \(b[]\) be two integer arrays of size \(n\). Following the examples of this section, give a formal description of the problem of determining if every element of \(a[]\) is also an element of \(b[] .\) The output of the algorithm should be one of the words "true" or "false."
Show that \(100 n^{3}+50 n^{2}+75\) is in \(\mathrm{O}\left(20 n^{3}\right)\) by finding a positive \(K\) that satisfies Equation (16.1) in this section
What do you think about this solution?
We value your feedback to improve our textbook solutions.