3 Problems on Algorithms - Homework 7 | CMSC 351, Assignments of Algorithms and Programming

Material Type: Assignment; Professor: Kruskal; Class: Algorithms; Subject: Computer Science; University: University of Maryland; Term: Summer I 2009;

Typology: Assignments

Pre 2010

Uploaded on 07/29/2009

koofers-user-acw
koofers-user-acw 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Summer 2009 CMSC 351: Homework 7 Clyde Kruskal
Due at the start of class, Wednesday, July 1.
Problem 1. Assume you have a list of nelements where the first n/k elements are the
smallest (but not sorted), the next group of n/k elements are the next smallest (but
not sorted), ..., and the last n/k elements are the largest (but not sorted). You may
assume kdivides n.
(a) Give an algorithm that sorts this list with as few comparisons as possible (as a
function of nand k). Just get the high order term right. How many comparisons
does your algorithm use?
(b) Show that your algorithm is optimal using a decision tree argument on the entire
list. (I.e., do not argue that you must solve kindependent sorting problems.)
Problem 2. Do Exercise 8.2-4 on page 170 of CLRS.
Problem 3.
(a) Illustrate the operation of radix sort on the following list of English words:
RUTS, TOPS, SUNS, SPOT, TONS, OPTS, TORS, SOTS, ROOT, OUTS,
SUPS, PUTT
(b) Write an English sentence using both “tor” and “sot” (that indicates you under-
stand the meanings of both words).

Partial preview of the text

Download 3 Problems on Algorithms - Homework 7 | CMSC 351 and more Assignments Algorithms and Programming in PDF only on Docsity!

Summer 2009 CMSC 351: Homework 7 Clyde Kruskal

Due at the start of class, Wednesday, July 1.

Problem 1. Assume you have a list of n elements where the first n/k elements are the smallest (but not sorted), the next group of n/k elements are the next smallest (but not sorted), ..., and the last n/k elements are the largest (but not sorted). You may assume k divides n.

(a) Give an algorithm that sorts this list with as few comparisons as possible (as a function of n and k). Just get the high order term right. How many comparisons does your algorithm use? (b) Show that your algorithm is optimal using a decision tree argument on the entire list. (I.e., do not argue that you must solve k independent sorting problems.)

Problem 2. Do Exercise 8.2-4 on page 170 of CLRS.

Problem 3.

(a) Illustrate the operation of radix sort on the following list of English words: RUTS, TOPS, SUNS, SPOT, TONS, OPTS, TORS, SOTS, ROOT, OUTS, SUPS, PUTT (b) Write an English sentence using both “tor” and “sot” (that indicates you under- stand the meanings of both words).