HW2 - CPS 130 Assignment II: Sorting and Search Trees...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CPS 130 Assignment II: Sorting and Search Trees Department of Computer Science - Duke University Due on Thursday 20 th Oct in Class 1 Give an O ( n log k ) time algorithm to merge k sorted lists into one sorted list, where n is the total number of elements in all the input lists. (Hint: Use a min-heap for k -way merging.) (15 points) 2 What is the worst-case running time for the bucket-sort algorithm? What simple change to the algorithm preserves its linear expected running time and makes its worst-case running time O ( n log n )? (15 points) 3 What does it mean for a sorting algorithm to be stable ? Prove that COUNTING-SORT is stable. Which of the following sorting algorithms are stable: insertion sort, merge sort and heapsort? Give a simple scheme that makes any sorting algorithm stable. How much additional time and space does your scheme entail? (20 points) 4 Suppose that we have numbers between 1 and 1000 in a binary search tree and want to search for the number 363. Which of the following sequences could not be the sequence
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 01/17/2012.

Ask a homework question - tutors are online