Department of Computer Science

Kent State University

CS 46101/56101 - Spring 2002

Design and Analysis of Algorithms


[Syllabus] [Grades] [Schedule] [Homework] [Lectures] [(F)AQ] [Home]



Question 1
on page 133 it says in the second last para that our tighter analysis relies on the properties that an n element heap has height floor(lg n) and at most ceiling(n/...) nodes of any height h. I dont understand what is h in this case. I understand the height is lg n but not the second part. If I try to substitute n=10 and h=1 in ceiling(n/...) for eg. I dont get the desired result.

ANSWER:
The height h in the term Ceiling(n/2**(h+1)) refers to the height of a particular node for which you want to determine the maximum number of nodes that may exist for a tree of that height.
If you are given a full binary tree containing 15 nodes the overhall height of the tree is lg 15 = 3. If you are concerned with a node on the third level of the tree, (Depth 2) than the height of that node is 2, and there are at most 4 nodes at height h=2 + the two nodes at height h-1, + the one node at the root, 15/2**3 = 7. Refer to page 1090 for a deatiled description of binary tree height.

problem 7-1 for the Hoare partition.
For parts b and c(since they are the loop invariants) do I show that it holds the three properties of initialization, maintenance and termination just as the book did for the quicksort. (There is an error(trivial) in the a) part it should be while loop and not for loop(this is not in the errata).)

ANSWER
Parts b, c, and d are concerned with proving the procedure correct. How you prove this is to prove the statements given in b, c, and d. Algebra should be a sufficent tool to do this.


Question 2
Regarding chapter 7 average case analysis of randomized quicksort, it assumes that we have done chapter 5 but we did skip that chapter. Do we have to study chapter 5 too? (I dont fully understand the method in the book). Or can I do the analysis in a different way like in class where Shannon used another method. Also, why do they choose a 9:1 split under the balanced partitioning performance. Is this a arbitrarily chosen ratio?

ANSWER
You should study Chapter 5 on your own. The choice of a 9:1 split is to demonstrate that quicksort still yeilds a running time of n lg n. A 9:1 split causes the two recursive calls to be made on very unequal subsets of the original array.


Question 3
Regarding chapter 6, in class you gave us the procedure for Down_Heapify. Does that correspond to Max-Heapify algorithm in the book? And does Up-Heapify(that you talked about) correspond to Min-Heapify(not given in the book). Please let me know if this is not right.

ANSWER
Yes you could consider Max-Heapify to correspond to Down-Heapify.


Question 4
Is our first midterm up until chapter 11?

ANSWER
The Mid-term will cover all material up to and including Chapter 11.