30.5 Exercises
Factual
- Suppose we have a sorted array in Java. What is the best approach for finding a particular item in the array: binary search or linear iteration? 
- Repeat the above exercise for a sorted array stored on physical tape. 
- Given the array - [90, 50, 20, 30, 40, 10, 60, 50, 30], what would be the best pivot?
Procedural
- If we have 10 items to sort, how many compares will it take to selection sort all of the items? 
- What is the depth of the quicksort recursive tree in the best and worst case? Give an exact answer, not a theta bound. 
Metacognitive
- Assume that we always pick the leftmost item as our pivot for quicksort. Identify the three types of arrays that will cause a worst-case runtime. For partitioning, assume that we partition into two arrays: items less than or equal to the pivot, and items greater than the pivot. 
Last updated