Chapter 2: Q17E (page 85)
Given a sorted array of distinct integers
Short Answer
By using binary search, only certain that there is no such value to the left of the middle element if
Chapter 2: Q17E (page 85)
Given a sorted array of distinct integers
By using binary search, only certain that there is no such value to the left of the middle element if
All the tools & learning materials you need for study success - in one app.
Get started for freeConsider the task of searching a sorted array
How many lines, as a function of n (in
print_line (โโstill goingโโ)
f (n/2)
f (n/2)
Section 2.2 describes a method for solving recurrence relations which is based on analyzing the recursion tree and deriving a formula for the work done at each level. Another (closely related) method is to expand out the recurrence a few times, until a pattern emerges. For instance, letโs start with the familiar
.
.
.
A pattern is emerging... the general term is
Plugging in
(a)Do the same thing for the recurrence
In justifying our matrix multiplication algorithm (Section 2.5), we claimed the following block wise property: if X and Y are
where A,B,C,D,E,F,G, and H are
Prove this property.
Question: On page 66 there is a high-level description of the quicksort algorithm.
(a) Write down the pseudocode for quicksort.
(b) Show that its worst - case running time on an array of size n is
(c) Show that its expected running time satisfies the recurrence relation.
Then, show that the solution to this recurrence is
What do you think about this solution?
We value your feedback to improve our textbook solutions.