1. Show that the running time of the merge-sort algorithm on an n-element sequence is O(nlogn), even when n is not a power of 22. Is our array-based implementation of merge-sort given in Section...
Articles Posted by admin
1. Given a sequence S of n values, each equal to 0 or 1, describe an in-place method for sorting S.2. Give an example input that requires merge-sort and heap-sort to take O(nlogn) time to sort, but...
1. Implement a bottom-up merge-sort for a collection of items by placing each item in its own queue, and then repeatedly merging pairs of queues until all items are sorted within a single queue.2....
Consider a version of deterministic quick-sort where we pick as our pivot the median of the d last elements in the input sequence of n elements, for a fixed, constant odd number d ≥ 3. What is the...
Suppose we are given two n-element sorted sequences A and B each with distinct elements, but potentially some elements that are in both sequences. Describe an O(n)-time method for computing a...
Recent Comments