The following given sequences list the nodes of a binary search tree in preorder and inorder respectively
preorder: G, B, Q, A, C, K, F, P, D, E, R, H
inorder: Q, B, K, C, F, A, G, P, E, D, H, R
Construct the binary tree..
Procedure:
Preorder traversal
(1) Visit the root
(2) Traverse the left sub-tree in preorder
(3) Traverse the right sub-tree in preorder
Inorder traversal
(1) Traverse the left sub-tree in inorder
(2) Visit the root
(3) Traverse the right sub-tree in inorder
0 comments:
Post a Comment