data structures - Binary Tree : pre order , inorder and post order -
can tell easy way traverse, if pre order given , have write post , pre order ? e.g if in order eackfhdbg have traverse in pre , post order?
just 1 of traversals in not sufficient construct tree. lead construct many possible trees.
we need in-order , 1 of pre-order/post-order/ level-order construct binary tree. refer http://www.geeksforgeeks.org/if-you-are-given-two-traversal-sequences-can-you-construct-the-binary-tree/
example:- in-order , pre-order given can print post-order. refer http://www.geeksforgeeks.org/print-postorder-from-given-inorder-and-preorder-traversals/
some other data along in-order can in constructin unique binary tree , hence can used derive other traversals. refer http://www.quora.com/given-an-in-order-traversal-of-a-special-binary-tree-having-property-that-the-node-is-always-greater-than-its-left-and-right-child-how-can-we-reconstruct-the-tree-efficiently
Comments
Post a Comment