CSCA48H3 Lecture Notes - Lecture 10: Binary Tree, If And Only If

75 views3 pages

Document Summary

Csca48 - lecture 09 - binary search trees def bst_search(root, value): Here, we are trying to search through the binary tree for the value we want. Based on our implementation of binary search trees, we understand that everything on the left side of the binary tree will be less than the elements on the right side of the tree. If we are searching for m", which does not exist in this binary tree, our method that we would have would be: The way this works is as follows: We are setting the current node point to where the root node is pointing to ( n") Next, we are running a while loop checking to make sure that we will continue to search. We will then have 2 cases to consider. The first is if the value we want is less than the current node we are on"s data.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents