hw2(2) - CS 373: Combinatorial Algorithms, Spring 2001...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 373: Combinatorial Algorithms, Spring 2001 Homework 2 (due Thu. Feb. 15, 2001 at 11:59 PM) Name: Net ID: Alias: U 3 / 4 1 Name: Net ID: Alias: U 3 / 4 1 Name: Net ID: Alias: U 3 / 4 1 Starting with Homework 1, homeworks may be done in teams of up to three people. Each team turns in just one solution, and every member of a team gets the same grade. Since 1-unit graduate students are required to solve problems that are worth extra credit for other students, 1-unit grad students may not be on the same team as 3/4-unit grad students or undergraduates. Neatly print your name(s), NetID(s), and the alias(es) you used for Homework 0 in the boxes above. Please also tell us whether you are an undergraduate, 3/4-unit grad student, or 1-unit grad student by circling U, 3 / 4 , or 1, respectively. Staple this sheet to the top of your homework. Required Problems 1. Suppose we are given two sorted arrays A [1 ..n ] and B [1 ..n ] and an integer k . Describe an algorithm to Fnd the k th smallest element in the union of A and B . (±or example, if k = 1, your algorithm should return the smallest element of A B ; if k = n , our algorithm should return the median of A B .) You can assume that the arrays contain no duplicates. ±or full credit, your algorithm should run in Θ(log n ) time. [Hint: First try to solve the special case k = n .] 2. Say that a binary search tree is augmented if every node v also stores | v | , the size of its subtree. (a) Show that a rotation in an augmented binary tree can be performed in constant time. (b) Describe an algorithm ScapegoatSelect ( k ) that selects the k th smallest item in an augmented scapegoat tree in O (log n ) worst-case time. (c) Describe an algorithm SplaySelect ( k ) that selects the k th smallest item in an aug- mented splay tree in O (log n ) amortized time.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 373 Homework 2 (due 2/15/2001) Spring 2001 (d) Describe an algorithm TreapSelect ( k ) that selects the k th smallest item in an aug- mented treap in O (log n ) expected time. 3. (a) Prove that only one subtree gets rebalanced in a scapegoat tree insertion. (b) Prove that
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

hw2(2) - CS 373: Combinatorial Algorithms, Spring 2001...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online