This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 6.006 Intro to Algorithms Recitation 03 February 9, 2011 Binary Search Tree A binary search tree is a data structure that allows for key lookup, insertion, and deletion. It is a binary tree, meaning every node of the tree has at most two child nodes, a left child and a right child. Each node of the tree holds the following information: x .key  Value stored in node x x .left Pointer to the left child of node x . NIL if x has no left child x .right  Pointer to the right child of node x . NIL if x has no right child x .parent  Pointer to the parent node of node x . NIL if x has no parent, i.e. x is the root of the tree Later on this week, we will learn about binary search trees that holds data in addition to the four listed above but for now we will focus on the vanilla binary search tree. A binary search tree has two simple properties: For each node x , every value found in the left subtree of x is less than or equal to the value found in x For each node x , every value found in the right subtree of x is greater than or equal to the value found in x 6.006 Intro to Algorithms Recitation 03 February 9, 2011 BST Operations There are operations of a binary search tree that take advantage of the properties above to search for keys. There are other operations that manipulate the tree to insert new key or remove old onesfor keys....
View
Full
Document
This note was uploaded on 11/11/2011 for the course MATH 180 taught by Professor Byrns during the Spring '11 term at Montgomery College.
 Spring '11
 byrns
 Math

Click to edit the document details