Challenge: Search Value in a Binary Tree
Let’s find a particular value in a binary tree.
We'll cover the following
Problem
Search for a particular value in the binary tree.
Input
An integer value and a binary tree.
Output
The program returns true
if the given value is present in a tree. Otherwise, it returns false
.
Sample input
The root node t.root
of the tree and an integer value called value
will be our inputs for the searchBT()
function.
Here’s the sample input.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.