recursion - Building tree from array -


i asked build tree array each element contained data node , level of node within tree. array preorder traversal of node.

i think solution wrong (or @ least not best way of doing it) i'm not sure why , right solution be.

my approach start level 0 on first call function , loop through array , when found level 1 greater level in current recursive call, make recursive call takes array starting @ index of element , increment level. then, result of recursive call child.

i check if level of element in array equal level in current recursive call- if so, break out of loop because sibling , don't want return sibling because parent take care of in recursive call.

does make sense? need change answer question correctly?


Comments

Popular posts from this blog

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -