ps5sol

ps5sol - Introduction to Algorithms Massachusetts Institute...

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

View Full Document Right Arrow Icon
Introduction to Algorithms October 30, 2006 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Madhu Sudan Problem Set 5 Solutions Problem Set 5 Solutions Problem 5-1. The Inconvenient Defense You are a Ph.D. student trying to organize your thesis defense. Your thesis committee has a very flexible timetable, so you get to choose to hold your defense at any time t within the interval [ T min , T max ) based on when your friends and acquaintances can attend. (Here [ a, b ) denotes the interval of all times t such that a t < b . For the purposes of this problem, your defense is a single point in time; you can think of this as when your defense starts.) To this end, you create a web form where your friends can post the time intervals when they can attend. Your server should automatically generate (and update) the “best” time for your defense. However, in order to minimize the number of awkward questions from the audience, your definition of “best” is the time that minimizes the number of attendees. Your goal is to create an efficient dynamic data structure that supports the following two operations: 1. I NSERT ([ a, b )) , which inserts the interval [ a, b ) (where T min a < b T max ) when a friend can attend. Each friend may post multiple intervals, but they are guaranteed to be disjoint. Different friends may post overlapping intervals. 2. P ERFECT -T IME () , which returns a time in [ T min , T max ) when the minimum number of people can attend your defense. You decide to create your data structure by augmenting a balanced binary search tree such as red-black trees or AVL trees. (a) Describe the data contained in each node of your augmented BST. ( Hint: Read the rest of the problem first.) Solution: For every time t that is either the beginning a or the end b of an interval [ a, b ) when a friend can attend, we keep a node with key t in an augmented red-black tree. (Since every key is unique, we hereafter simply say “ t ” instead of “the node whose key is t
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/20/2012 for the course CS 6.006 taught by Professor Erikdemaine during the Fall '08 term at MIT.

Page1 / 3

ps5sol - Introduction to Algorithms Massachusetts Institute...

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

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