Lecture22

Lecture22 - lookup(D) M H D B F J K N Q S O V lookup(C) M H...

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

View Full Document Right Arrow Icon
lookup(D) M Q D H N J S V O K F B
Background image of page 1

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

View Full DocumentRight Arrow Icon
lookup(C) M Q D H N J S V O K F B
Background image of page 2
add(C) M Q D H N J S V O K F B
Background image of page 3

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

View Full DocumentRight Arrow Icon
add(T) M Q D H N J S V O K F B
Background image of page 4
remove(K) M Q D H N J S V O K F B
Background image of page 5

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

View Full DocumentRight Arrow Icon
remove(N) M Q D H N J S V O K F B
Background image of page 6
remove(Q) M Q D H N J S V O K F B
Background image of page 7

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

View Full DocumentRight Arrow Icon
remove(H) M Q D H N J S V O K F B
Background image of page 8
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 9 Announcements Announcements o Deb's New Office: 5376 CS Walk in CS Advising  Location: 25 Ingraham Hall Date/Time:  Monday 11/22 2-4pm Wednesday 12/1 2-4pm A4: BSTree Available Friday pm
Background image of page 9

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

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 10 Last Lecture Last Lecture o Depth-first vs Breadth-first traversals Binary Tree Examples Binary Search Tree Expression Trees Binary Heaps Implementation Array vs Linked Node
Background image of page 10
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 11 This Lecture This Lecture o BST Class BST Algorithms Insert - add new data Lookup - find existing data Remove - find and remove existing data
Background image of page 11

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

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12 Binary Search Tree Interface Binary Search Tree Interface public interface BSTreeInterface extends TreeInterface { public boolean contains( Comparable key ); // if duplicate, throw exception public void add( Comparable key, Object data ) ; // null, if not found public void remove( Comparable key ) ; // null, if not found public Object lookup( Comparable key ) ; // iterates in sorted order public java.util.Iterator getInorderIterator(); }
Background image of page 12
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 13 Object lookup(Comparable key) Object lookup(Comparable key) o if root is null, return null else if key is same as root's key, return root.data else if key < root's key, return leftSubtree.lookup(key) else return rightSubtree.lookup(key);
Background image of page 13

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

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 14 M Q O D H N J F B K V S Try It Try It o S.o.p(tree.lookup("D")) BST root node key D key node key node key
Background image of page 14
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 15 Try It Try It o BST root node key node key node key node key null M Q O D H N J F B K V S C key
Background image of page 15

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

View Full DocumentRight Arrow Icon
05/13/09 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission.
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/17/2011 for the course CS 367 taught by Professor Marvinsolomon during the Spring '08 term at Wisconsin.

Page1 / 42

Lecture22 - lookup(D) M H D B F J K N Q S O V lookup(C) M H...

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

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