Question: Referring back to the searching problem
Referring back to the searching problem (see Exercise 2.1-3), observe that if the sequence A is sorted, we can check the midpoint of the sequence against v and eliminate half of the sequence from further consideration. Binary search is an algorithm that repeats this procedure, halving the size of the remaining portion of the sequence each time. Write pseudo code either iterative or recursive, for binary search, argue that the worst-case running time of binary search is Θ (lg n).
Answer to relevant QuestionsObserve that the while loop of lines 5 - 7 of the INSERTION-SORT procedure in Section 2.1 uses a linear search to scan (backward) through the sorted subarray A[1 ¬ j - 1]. Can we use a binary search (see Exercise 2.3-5) ...Explain why the statement, "The running time of algorithm A is at least O (n2)," is meaningless.In HIRE-ASSISTANT, assuming that the candidates are presented in a random order, what is the probability that you will hire exactly one time? What is the probability that you will hire exactly n times?Explain how to implement the algorithm PERMUTE-BY-SORTING to handle the case in which two or more priorities are identical. That is, your algorithm should produce a uniform random permutation, even if two or more priorities ...Why do we analyze the average-case performance of a randomized algorithm and not its worst-case performance?
Post your question