|
i thought calling it recursively is the easiest way to do it. The number is supposed to be inserted in the next available spot going left to right. So the number the user entered is supposed to be added to the next available spot and then you compare that node with all the nodes before it and if its smaller than the parent node you swap the values because the lowest value has to be the root. I am checking when they are null because when one is null thats where the new value goes or something like that? Like i get the idea of inserting and swapping and stuff on paper with a picture of a tree and stuff but i have no clue how it should be programmed or anything.
|