Preview

7.2-3 Show That The Splits At Every Level Of Quicksort?

Good Essays
Open Document
Open Document
1551 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
7.2-3 Show That The Splits At Every Level Of Quicksort?
7.2-3 Show that the running time of QUICKSORT is ‚.n2/ when the array A contains distinct elements and is sorted in decreasing order.
QUICKSORT becomes T(n)=T(n-1)+∅(n)
T(n)=T(n-1)+∅(┤)
=T(n-2)+∅(n-1)+∅(n)
=T(n-3)+∅(n-2)+∅(n-1)+∅(n)
=∅(n)+∅∑_(k=1)^n▒k
=∅(n^2)
7.2-5 Suppose that the splits at every level of quicksort are in the proportion 1˛ to ˛, where 0<˛ 1=2 is a constant. Show that the minimum depth of a leaf in the recursion tree is approximately lgn=lg˛ and the maximum depth is approximately lgn=lg.1˛/. (Don’t worry about integer round-off.)
For the minimum depth, it follows a path. This path is one that is a smaller part of the partition. For example, the partition multiplies the number of elements by α. One iteration of minimum depth reduces the number of elements from n to αn. It then takes that iterations, and reduces the number of
…show more content…
Where does your proof need the assumption that the intermediate sort is stable?

Base step: Assume that d=1. That is, there is only single digit in the given numbers. Then radix sorts the array on that single digit. That is, of d=1, radix sort performs sort on one column and gives the sorted array. Therefore, radix sort works for single digit numbers.
Sort on the dth digit:
In the proof, the assumption that the intermediate sort is stable. This is required when sorting numbers on their d^thdigit. Also who’s d^thdigits were equal. Since the d^thdigits were equal, the correct order of numbers is already determined. This is by after sorting by their lower-order d-1 digits. If the intermediate sort was not stable, the numbers correctly ordered by sorting on their lower ordered d-1 digits are rearranged. This is done while sorting on d^thdigit.The assumption is required when sorting numbers on their d^th digit. And also who’s d^thdigits were equal.
12.1-1 for the set of {1,4,5,10,16,17,21} of keys, draw binary search trees of height 2,3,4,5 and 6
Height 1

Height

You May Also Find These Documents Helpful