This preview has intentionally blurred sections. Sign up to view the full version.
View Full 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.21 (page 228) • CLRS 11.22 (page 229) • CLRS 11.31 (page 236) • CLRS 11.33 (page 236) • Prove that redblack trees are balanced, i.e., if a redblack tree contains n nodes, then its height is O (log n ). Redblack 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
 Spring '08
 ErikDemaine
 Algorithms, Big O notation, hash function, Substring

Click to edit the document details