We need a tree where anytime we should be able to travel from leaf node to root or root node to leaf, as well as well it’s should also support basis tree traversing like PRE, POST ,INORDER, LVEVL ORDER. So question is what data structure should we use to store tree or make such tree?


Answer: – We can store such tree in HashMap with key-value pair and each. Where key and value are TreeNode. And each TreeNode is having actual data as payload member and as well as it is also maintaining association details with parent and child nodes.