Exercises 4.5
1. a. If we measure an instance size of computing the greatest common divi-
sor of and by the size of the second number ,byhowmuchcanthe
size decrease after one iteration of Euclid’s algorithm?
2. Apply quickselect to find the median of the list of numbers 9, 12, 5, 17,
20, 30, 8.
3. Write pseudocode for a nonrecursive implementation of quickselect.
7. a. Outline an algorithm for finding the largest key in a binary search tree.
Would you classify your algorithm as a variable-size-decrease algorithm?
b.Whatisthetimeefficiency class of your algorithm in the worst case?
9. Outline a variable-size-decrease algorithm for constructing an Eulerian
circuit in a connected graph with all vertices of even degrees.
10. Misere one-pile Nim Consider the so-called misere version of the one-
pile Nim, in which the player taking the last chip looses the game. All
11. Ba. Moldy chocolate Two payers take turns by breaking an ×choco–
late bar, which has one spoiled 1-by-1square. Each break must be a single
straight line cutting all the way across the bar along the boundaries be-
tween the squares. After each break, the player who broke the bar last
39