Uploaded by vbrjplkbttwauidxus

DSA Lab Sheet

advertisement
DSA Lab Sheet – 8 (L55+L56)
Exercises
Q1. Binary Tree Traversal (Recursive implementation)
(i) Implement Preorder, Inorder and Postorder traversal operations. Traverse the tree
given in the above example.
Use the following tree as input:
Expected output:
PREORDER - 60, 70, 20, 28, 55, 90, 88
INORDER - 28, 20, 70, 55, 60, 90, 88
POSTORDER - 28, 20, 55, 70, 88, 90, 60
(ii) Modify your program to find inorder predecessor of given key values. You may
implement this as a separate function black.
Q2. Binary search tree (BST) Implementation
Data set: 15, 10, 20, 8, 25, 18, 12, 19, 30
(i)
Insertion in BST
(ii)
Search given key in BST:
Search keys: 12, 25 (return with location info)
Deletion from BST
(iii)
**************************************************************
Note:



Your submission should contain - program, screenshots of input and output.
You should print your Name & Register number before printing the output.
Submit it before the deadline (in either word or PDF format).
**************************************************************
Download