

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Main points of this past exam are: Pseudocode, Young Tableau, Minimum Element, Provide a Pseudocode, Algorithm Sorts, Storate Space, Query Operations
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!
CSE3358 Problem Set 5 02/11/ Due 02/18/
Problem 1: Young tableau An m × n Young tableau is an m × n matrix such that the entries of each row are in sorted order from left to right and the entries of each column are in sorted order from top to bottom. Some of the entries of a Young tableau may be ∞, which we treat as nonexistent elements. Thus a Young tableau can be used to hold r ≤ mn numbers.
Here’s an example of a 4x4 Young tableau containing the elements { 9 , 16 , 3 , 2 , 4 , 8 , 5 , 14 , 12 }. Note that this is not unique.
(^2 4 9) ∞
(^3 8 16) ∞
5 14 ∞ ∞
12 ∞ ∞ ∞
(a) (5 points) Argue that an m × n Young tableau Y is empty if Y [1, 1] = ∞. Argue that Y is full (contains mn elements) if Y [m, n] < ∞.
(b) (5 points) Argue that the minimum element of a Young tableau Y is always in Y [1, 1].
(c) (10 points) Give an algorithm to implement EXTRACT-MIN on a nonempty m × n Young tableau that runs in O(m + n) time. Your algorithm should use a recursive subroutine that solves an m × n problem by recursively solving either an (m − 1) × n or an m × (n − 1) subproblem. Define T (p), where p = m + n, to be the maximum running time of EXTRACT-MIN on any m × n Young tableau. Give and solve a recurrence for T (p) that yields the O(m + n) time bound.
(d) (10 points) Show how to insert a new element into a nonfull m × n Young tableau in O(m + n) time.
(d) (10 points) Using no other sorting method as subroutine, show how to use an n × n Young tableau to sort n^2 numbers in O(n^3 ) time. Based on this, describe a sorting algorithm that has an O(n^1.^5 ) worst-case running time.
(e) (0 points) I will not ask: given n distinct elements, how many Young tableaus can you make?
Problem 2: Sometimes you just have to count (10 points) Describe an algorithm that, given n integers in the rangle 0 to k, preprocesses its input and then answers any query about how many of the n integers fall into a rangle [a..b] in O(1) time. Your algorithm should use Θ(n + k) prepreocessing time. For full credit you should
Problem 3: S0rt1ing revisited Suppose that we have an array of n data records to sort and that the key of each record has the value 0 or 1. An algorithm for sorting such a set of records might possess some subset of the following three desirable properties:
(a) (5 points) Describe an algorithm that possesses properties (1) and (2).
(b) (5 points) Describe an algorithm that possesses properties (2) and (3).
(c) (10 points) Describe an algorithm that possesses properties (1) and (3).
For full credit you should in each case: