This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Assignment 3 (revised version). CS341, Spring 2009 Distributed Tuesday, June 9, due 3pm July 7, 2009. Hand in to the assignment boxes on the 3rd floor of MC. 1. (10 marks) Consider the edit distance problem: given two sequences X of length m , and Y of length n , over a fixed alphabet , we wish to find the smallest number of edit operations (insert a single character, delete a single character, and replace a single character by another) to convert X to Y. Give a dynamic programming formulation for this problem. 2. (10 marks) Assume we have k stacks (last-in fist-out devices) lined up as S 1 , . . ., S k . A permuation of n numbers come one by one in the online fashion (once a number passes by, we do not see it or remember it any more). Each number x sequentially goes through stacks S 1 to S k in the following fashion. At each stack S i , you can first pop some elements out from S i and send them, in the order they are popped out, to the next stack S i +1 (or output if it is popped from the last stack S k ), then you push x into S i . Show: (a) log n stacks are sufficient to sort n numbers (i.e. when they come out of the last stack, they should be in sorted order). (b) Using an incompressibility argument to prove a lower bound of 1 2 log n . That is: 1 2 log n stacks are necessary. Open question (you get an automatic 100 for the course if you solve this): close the gap between the lower bound of 1 2 log n and the upper bound of log n ....
View Full Document
This note was uploaded on 10/23/2009 for the course CS 341 taught by Professor ? during the Spring '09 term at Waterloo.
- Spring '09