7.3-bst - CMPT 225 Binary Search Tree CMPT 225 CMPT 225 A...

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

View Full Document Right Arrow Icon
CMPT 225 Binary Search Tree
Background image of page 1

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

View Full DocumentRight Arrow Icon
CMPT 225
Background image of page 2
CMPT 225 A binary search tree – Fig. 11.19
Background image of page 3

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

View Full DocumentRight Arrow Icon
CMPT 225 BST Operations Create a BST (empty, or with a root) Insert an element Remove an element Search for an element Retrieve an element Traverse Size Find successor of an element Find predecessor of an element Find minimum element of a BST Find maximum element of a BST
Background image of page 4
CMPT 225 Search Algorithm: if tree empty -> element not there! if element is in root -> done! -> return root otherwise if element < element stored in root search left subtree • else search right subtree element -> key value of element we are looking for
Background image of page 5

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

View Full DocumentRight Arrow Icon
Insert • Algorithm: • if tree empty -> insert new element in root • otherwise if new element < element stored in root insert into left subtree • else insert into right subtree element -> key value of element we are looking for
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/29/2012 for the course CMPT 225 taught by Professor Annelavergne during the Summer '07 term at Simon Fraser.

Page1 / 12

7.3-bst - CMPT 225 Binary Search Tree CMPT 225 CMPT 225 A...

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

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