CS511 Graduate Algorithms Quiz 2 May 12, 2009 Answer all three - - PDF document

cs511 graduate algorithms quiz 2
SMART_READER_LITE
LIVE PREVIEW

CS511 Graduate Algorithms Quiz 2 May 12, 2009 Answer all three - - PDF document

CS511 Graduate Algorithms Quiz 2 May 12, 2009 Answer all three questions. Total time: 2 hours Any violation of the following rules will get you a 0 in the quiz. No textbooks are allowed. Only notes/slides from the lectures


slide-1
SLIDE 1

CS511 – Graduate Algorithms Quiz 2

May 12, 2009

Answer all three questions. Total time: 2 hours Any violation of the following rules will get you a 0 in the quiz.

  • No textbooks are allowed.
  • Only notes/slides from the “lectures” page are allowed.
  • Turn your cell phones off.
  • Put your bags, belongings and cellphones in front of the class.
  • Do your rough calculations and thinking on the extra booklet. Only write your final answers

neatly on the answer booklet. I will grade according to what I can read. 1

slide-2
SLIDE 2

Q1.

  • 1. A Fibonacci tree of order k, denoted Fk, is defined recursively as follows: F1 and F2 are single

nodes, and Fk consists of an Fk−2 linked to an Fk−1. Prove that for any node in a Fibonacci tree, height(v) = ⌈degree(v)/2⌉.

  • 2. Prove that only one subtree gets rebalanced in a scapegoat tree insertion.

10 + 10 points

slide-3
SLIDE 3
slide-4
SLIDE 4
  • Q2. The staircase of a set of points consists of the points with no other point both above and

to the right. Describe a method to maintain the staircase as new points are added to the set. Specifically, describe and analyze a data structure that stores the staircase of a set of points, and an algorithm INSERT(x, y) that adds the point (x, y) to the set and returns TRUE or FALSE to indicate whether the staircase has changed. Your data structure should use O(n) space, and your INSERT algorithm should run in O(log n) amortized time. 20 points

slide-5
SLIDE 5
slide-6
SLIDE 6
  • Q3. Suppose you are given an array of n numbers, sorted in increasing order.
  • Describe an O(n)-time algorithm for the following problem: Find two numbers from the list

that add up to zero, or report that there is no such pair. In other words, find two numbers a and b such that a + b = 0.

  • Describe an O(n2)-time algorithm for the following problem: Find three numbers from the list

that add up to zero, or report that there is no such triple. In other words, find three numbers a, b, and c, such that a + b + c = 0. 10 + 10 points

slide-7
SLIDE 7