Binary Search Tree (Find Value) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Binary Search Tree (Find Value)

I create data such as map implementation, and make the key to be an example create a binary search tree. but difficult if you want to find a value from the binary search tree like this : BinarySearchTree bst = new BinarySearchTree(); bst.addData(100, "First"); bst.addData(50, "Second"); bst.addData(300, "Third"); bst.addData(400, "Fourth); Result 100 | First 50|Second. 300 | Third 400| Fourth So how to find value Fourth ?

9th Dec 2017, 3:40 PM
Nazhan Harzula
Nazhan Harzula - avatar
1 Answer
0
In general you would go to 100, the choose node to the right which is 300 and make it your "current" node. Then choose the right child of 300, which is 400 and now this is your current node. Hope this makes sense and helps.
10th Dec 2017, 11:01 AM
Ryan Wakefield
Ryan Wakefield - avatar