lecture-14

The item to be removed is not in the tree the node

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: he nodes by printing them to an output stream (out) –  To print, use Entry’s operator<< method out << subTreeRoot->item; –  The result should look like a dictionary file You’ll need to create –  Helper methods for the recursion, e.g., Dictionary’s << should use inorder void prePrintTraversal(const Node*, ostream&) –  These methods should be declared protected or private CPSC 223  ­ ­ Fall 2010 28 14 10/19/10 Binary Search Tree Deletion CPSC 223  ­ ­ Fall 2010 29 Removing (Deleting) Nodes •  Removing nodes is where things get tricky … •  If we could restrict remove to just leaf nodes it would be easy •  For general removal, we need to consider some special cases … CPSC 223  ­ ­ Fall 2010 30 15 10/19/10 Removing Nodes Cases to consider … –  The tree is empty! –  The item to be removed is not in the tree –  The node containing the item is a leaf node –  The node containing the item has one child –  The node containing the item has two children CPSC 223  ­ ­ Fall 2010 31 Removing Nodes •  To remove a leaf n...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online