Practice 1
We highly encourage being environment friendly and trying all problems on your own.
1. Implement MergeSort.
2. Implement Insertion Sort.
3. Implement QuickSort.
(optional)
4. Implement priority queue.
5. Implement Quicksort and answer the following questions. (1) How many comparisons will Quicksort do on a list of n elements that all have the same value? (2) What are the maximum and minimum number of comparisons will Quicksort do on a list of n elements, give an instance for maximum and minimum case respectively.
6. Give a divide and conquer algorithm for the following problem: you are given two sorted lists of size m and n, and are allowed unit time access to the ith element of each list. Give an O(lg m + lgn) time algorithm for computing the ksort of given什么意思th largest element in the union of the two lists. (For simplicity, you can assume that the elements of the two lists are distinct).
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论