Binary Search Tree Traversal
Aim : To create a binary search tree and do the following traversal
Algorithm :
Preorder Traversal
preorder(node)
print node.value
if node.left ≠ null then preorder(node.left)
if node.right ≠ null then preorder(node.right)
Inorder Traversal
inorder(node)
if node.left ≠ null then inorder(node.left)
print node.value
if node.right ≠ null then inorder(node.right)
Post Order Traversal
postorder(node)
if node.left ≠ null then postorder(node.left)
if node.right ≠ null then postorder(node.right)
print node.value
No comments:
Post a Comment