Ok so this is my task:
Description:

Create a generic class called GenBinTree. GenBinTree will use nodes
that store a value of the generic type to store its contents.
This tree will not be a search tree (no ordering of nodes by value).

What ges me its the the part that says it will not be a search tree, from what i see dont get how a tree can be a tree withouth being a search tree, I do not understand how to implement a tree with the given criteria.

## All 5 Replies

A tree is not a search tree when it is used to store certain data that may not be comparable. For example, you want to store data that just need to fill into a tree with at most 3 branches. Though, the tree may require to know what the current height it is because you are not going to search the tree.

/*
For example... I declare a tree that can have at most 3 branches...
Start, current height = 0
Input "m"
root is "m", current height = 1
Input "a"
check current height is full (only 1 node at root),
increment the current height and insert the item
tree becomes...          m            current height = 2
/  |  \
a    nl  nl
/|\
nlnlnl
Input "k"
tree becomes...       .  m  .         current height = 2
/    |    \
a      k      nl
/|\    /|\
nlnlnl nlnlnl
Input "e"
tree becomes...       .  m  .         current height = 2
/    |    \
a      k      e
/|\    /|\    /|\
nlnlnl nlnlnl nlnlnl
Input "m"
check current height is full (all 3),
increment the current height and insert the item
tree becomes...       .  m  .         current height = 3
/    |    \
a      k      e
/|\    /|\    /|\
m nlnl nlnlnl nlnlnl
/|\
nlnlnl
*/

i understand i belive , so for a binary tree the most number of brancher is two of course, does the data get inserted from left to right am guessing? for example

k    insert a  k    insert z    k
/ \             /\              /\
b               b  a            b   c
/\   /\
z

while checking that the the hegiht is not full instead of comparing the data?

Yes, you could assume that the data is entered from left to right without any comparison.

Ok so i just started my program but actually found out that the position of the new node or whatever is being inserted will be in a randomm position, heres what the book says