Question: Professor Marceau objects to the loop invariant used in
Professor Marceau objects to the loop invariant used in the proof of Lemma 5.5. He questions whether it is true prior to the first iteration. His reasoning is that one could just as easily declare that an empty subarray contains no 0-permutations. Therefore, the probability that an empty subarray contains a 0-permutation should be 0, thus invalidating the loop invariant prior to the first iteration. Rewrite the procedure RANDOMIZE-IN-PLACE so that it’s associated loop invariant applies to a nonempty subarray prior to the first iteration, and modify the proof of Lemma 5.5 for your procedure.
Answer to relevant QuestionsSuppose that instead of swapping element A[i] with a random element from the subarray A[i ..n], we swapped it with a random element from anywhere in the array: PERMUTE-WITH-ALL (A) 1 n ← length [A] 2 for i ...Show that in any sub tree of a max-heap, the root of the sub tree contains the largest value occurring anywhere in that sub tree.Show that quick sort's best-case running time is Ω (n lg n).Show that the second smallest of n elements can be found with n + ⌈lg n⌉ - 2 comparisons in the worst case.Consider a version of the division method in which h (k) = k mod m, where m = 2p – 1 and k is a character string interpreted in radix 2p. Show that if string x can be derived from string y by permuting its characters, then ...
Post your question