It means that if you randomly pick a number from 1~7, you should get a different binary tree when you do an insertion. For example, if you draw a number from 1~7 and the result of the order is 1, 2, 3, 4, 5, 6, 7, you will get a long tree line when you build a binary tree (using binary tree insertion rules).
You are on the right track. Unfortunately, the tree you created is not a balanced tree. You need to apply the insertion rules of binary tree.
- If the current node is null, assign the inserting value to the node and done.
- If it is not null, compare the value of the node with the inserting value.
- If the inserting value is less than the current node value, traverse to the left child
- Otherwise, traverse to the right child
In your tree, the random order could be "4, 3, 2, 1, 5, 6, 7" and there are 12 comparisons to create the tree. The balanced tree will have only 10 comparisons.