Using the structure node
described as below :
struct node { struct node *left, *right; int value; };
Here's an exemple of a tree generated by this structure:
You have to create a tree by calling the function add
repetitively. The function
search
must check efficiently if the tree contains a certain value.
We will use a binary ordered tree, with all nodes at right having their value
greater the the value of root node, and the nodes at left will have their value
less than the one of root node. If a value is already contained in the tree, you shouldn't add any new node.
Example of the behaviour when calling add: