CS2003 Data Structures and Algorithms Lab
Date 09/10/2020 Time : 5 to 6.30pm
Binary Tree and Binary Search Tree
Q1. Recall that inorder traversal of a binary expression tree gives infix notation of the
expression.
A+B
+
A B
a. Construct a binary tree for the given expression.
b. Perform inorder, preorder, and postorder traversals of the tree and verify that the
traversal sequence represent infix, prefix and postfix notation of the expression
Q2. A. Construct a binary tree T given either {preorder and inorder} or {postorder and
inorder} traversals of the tree.
B. Print height of the tree T that you have constructed. Write your own function for
determining height of the tree.
C. Write a function checkCousins(x, y) that checks whether two nodes in the tree T
are cousins. (nodes in the same level but having different parent)
C
A B
D E F G
Cousins : (D, F) (E, F) , (D,G), (E, G)