HW3 - become empty then we attach the remaining numbers to the end of the new list and it's done This takes linear time Now try to give an

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

View Full Document Right Arrow Icon
CSCI 570 Homework Set 3 Instructor: Prof. Shamsian Due on Sep. 25th, 2009 1. Problem 3 in Chapter 4 2. Problem 4 in Chapter 4 3. When we have two sorted lists of numbers in non-descending order, and we need to merge them into one sorted list, we can simply compare the first two elements of the lists, extract the smaller one and attach it to the end of the new list, and repeat until one of the two original lists
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: become empty, then we attach the remaining numbers to the end of the new list and it's done. This takes linear time. Now, try to give an algorithm using time to merge k sorted lists (you can also assume that they contain numbers in non-descending order) 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.) ( log ) O n k...
View Full Document

This note was uploaded on 01/22/2010 for the course CSCI 570 taught by Professor Shamsian during the Fall '06 term at USC.

Ask a homework question - tutors are online