{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

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

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

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

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

View Full Document Right Arrow Icon
remove(N) M Q D H N J S V O K F B
Image of page 6
remove(Q) M Q D H N J S V O K F B
Image of page 7

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

View Full Document Right Arrow Icon
remove(H) M Q D H N J S V O K F B
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
Image of page 9

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

View Full Document Right 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
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
Image of page 11

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

View Full Document Right 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(); }
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);
Image of page 13

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

View Full Document Right 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
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 S.o.p(tree.lookup("C")) 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
Image of page 15

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern