Step 5: Searching for a node in the tree
To search for a node in the tree, we need a recursive function find(). This function firstly tests whether the tree is empty. If the tree is not empty, the target value is compared firstly with the data of the root node. If the target value is less than the data of the root node, the search process will continue to left side. It continues to the right side if the target value is greater than the data. The process stops when the data of a node is equal to the target value or when it reaches the end of the tree.
template <class Type>
Node<Type> *BSTree<Type>::find(Node<Type> *T, const Type Tar)
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: