If a binary tree can be represented with the array data structure in an efficient way(it means there is no blank key in b/w two non-zero elements) then it cannot be designed uniquely with the help of which of the following traversals?


Please answer this question.It is quite tricky for me.

6 Years
Discussion Span
Last Post by Taywin

What does it mean by "blank key"? The array type you need must be dynamic - change in size whenever an insert occurs (and may be remove). And can the value inside the array be an Object or just a plain value?


OK, if no null value between, I doubt that you could accomplish this using plain value for each node. You would need an object which hold the node value and its child node index in the array. If there is no child, the value of the index should be negative. Then you can simply add the node to the dynamic array (just push) when you insert, but you need to update its parent's child node index as well. Does that work?

PS: You need to implement a way to remove and move around the subtree which belongs to the deleting node. It shouldn't be that difficult.

Edited by Taywin: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.