|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Problems
Problem 2.1:
Why would happen if binary search were called on an unsorted array?
[Solution]
Problem 2.2:
Does the middle pointer necessarily have to be given the value
(first + last) / 2, or could it be any value in between first and last?
[Solution]
Problem 2.3:
theSpark.com stores their user database in a big array, sorted
alphabetically by user name. The array contains 2.5 million elements.
How many comparisons, at most, will it take their binary search algorithm
to locate the data it is searching for?
[Solution]
Problem 2.4:
If you were to be doing many searches on a sorted linked list of n
elements, how might you transform the list to increase the efficiency
in the long run?
[Solution]
Problem 2.5:
Someone gives you an array of integers sorted in descending order. Rewrite
the binary search code to account for this.
[Solution]
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contact Us | Privacy Policy | Terms and Conditions | About
©2006 SparkNotes LLC, All Rights Reserved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||