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

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -