ps2 - MIT OpenCourseWare http://ocw.mit.edu 6.006...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: MIT OpenCourseWare http://ocw.mit.edu 6.006 Introduction to Algorithms Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms . Introduction to Algorithms: 6.006 Massachusetts Institute of Technology Feb 21, 2007 Professors Srini Devadas and Erik Demaine Handout 4 Problem Set 2 This problem set is due Thursday March 6 at 11:59PM . Solutions should be turned in through the course website in PDF form using L A T E X or scanned handwritten solutions. A template for writing up solutions in L A T E X is available on the course website. Remember, your goal is to communicate. Full credit will be given only to the correct solution which is described clearly. Convoluted and obtuse descriptions might receive low marks, even when they are correct. Also, aim for concise solutions, as it will save you time spent on write- ups, and also help you conceptualize the key idea of the problem. Exercises are for extra practice and should not be turned in. Exercises: CLRS 11.2-1 (page 228) CLRS 11.2-2 (page 229) CLRS 11.3-1 (page 236) CLRS 11.3-3 (page 236) Prove that red-black trees are balanced, i.e., if a red-black tree contains n nodes, then its height is O (log n ). Red-black trees are binary search trees satisfying the following properties: 1. Each node is augmented with a bit signifying whether the node is red or black. 2. If a node is red, then both of its children are black. 3. The paths from the root to any leaf contain the same number of black nodes. 1. (12 points) select in Binary Search Trees Implement select in bstselect.py . select takes an index, and returns the element at that index, as if the BST were an array. select is essentially the inverse of rank , which took a key and returned the number of elements smaller...
View Full Document

Page1 / 5

ps2 - MIT OpenCourseWare http://ocw.mit.edu 6.006...

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