CSC148H5 Lecture Notes - Lecture 20: Binary Search Tree, University Of Toronto Mississauga, Init

33 views6 pages

Document Summary

Csc148h5s - introduction to computer science (winter 2017) We have seen two ways to represent trees. We"ll use a form of nodes and references to represent a bst. We"ll use a btnode class to represent a node in the bst. We"ll use a bs t class to represent the tree itself. The bst class has a root attribute that is. A reference to the root btnode of the tree. Depends on the where the node exists in the tree. We must be able to delete the node without violating the bst property. To delete a node with a single child, cut out that node. When a node has two children, it may not be correct to move one of the children up eg. removing 4 in the example below. To delete a node with two children, replace it by its predecessor. This yields a new bst that cannot violate the bst property.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents