Tree Lectures SSB
-
Upload
sartaj-singh -
Category
Documents
-
view
217 -
download
0
description
Transcript of Tree Lectures SSB
-
Launchpad
Data Structures Trees - 3
Friday, July 25, 2014
Anushray Gupta
-
Any doubts?
Friday, July 25, 2014 2
-
Binary Search Trees
Friday, July 25, 2014 3
-
BST Properties
1. Every Node in left sub-tree has value less than or equal to root
2. Every Node in right sub-tree has value greater than or equal to root
Friday, July 25, 2014 4
-
Binary Search trees
Friday, July 25, 2014 5
-
Binary Search Trees
class BinarySearchTree { Node * root; // accessor methods int size(); boolean isEmpty(); Node *findElement(int element); Node *findMinimum(); Node *findMaximum(); // update methods void addElement(int element); void removeElement(int element); void removeMin(); Void removeMax();
}
Friday, July 25, 2014 6
-
Lets discuss few problems
1. Print BST elements in range K1 and K2 2. Find successor of a given node
Friday, July 25, 2014 7
-
Time to try?
1. Given a binary tree check if its BST 2. Given preorder traversal of a binary
search tree, construct the BST
Friday, July 25, 2014 8
-
Build a BST using a sorted array
Friday, July 25, 2014 9
-
Balanced/unbalanced Tree
Friday, July 25, 2014 10
-
Balanced Trees
1. AVL Tree 2. Red Black Trees 3. 2-4 Trees
Friday, July 25, 2014 11
-
Thank You!
Anushray Gupta +91-9555567876 [email protected]
Friday, July 25, 2014 12