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?

1.Preorder
2.Inorder
3.Postorder

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

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?

blank key means null no 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.