DOCtopo
DOCtopo
2023-24
Module4: Trees
Practice Questions
(2M)
5) What are the two ways of representing binary trees in memory? Which one do you
prefer and why?
6) Draw the memory representation for the following trees(linked representation and
sequential representation).
Tree-1
Tree-2
7) Convert the following infix expression into prefix expressions.
i) (A-B)*(C +D)
ii) (A+B)*C
i) (A-B)*(C +D)
ii) (A+B)*C
8) Discuss Best case, average case and worst case time complexity of an algorithm with
Example.
9) Consider the tree given below. Now, do the following: (a) Name the leaf nodes (b) Name
the non-leaf nodes (c) Name the ancestors of E (d) Name the descendants of A (e) Name
the siblings of C (f) Find the height of the tree (g) Find the height of subtree rooted at E
(h) Find the level of node E (i) Find the in-order, pre-order, post-order
1) Explain the terms infix expression, prefix expression and postfix expression.
2) Write a C Program to implement stack using array
3) Define recursion. Write a C program to check whether a string is palindrome or not, with the
help of stack data structure.
4) Implement Linear Queue ADT.
5) Write short notes on: (a) Complete binary trees (b) Extended binary trees (c) Tournament
trees (d) Expression trees (e) General tree
6) find the sequence of nodes that will be visited using pre-order traversal algorithm and post-
order traversal .
7) find the sequence of nodes that will be visited using pre-order traversal algorithm and post-
order traversal algorithm.
i) (A-(B/C+(D%E*F)/G)*H
ii) 9-((3*4)+8)/4
iii)x^y/(5*z)+2
iv) A+B-C*D
9) Create a binary search tree using the following data elements: 45, 39, 56, 12, 34, 78, 32, 10,
89, 54, 67, 81
10) Given an expression, Exp = ((a + b) – (c * d)) % ((e ^f) / (g – h)), construct the
corresponding binary tree.
11) Explain the properties of Binary Search Tree. Create a binary search tree using the
following data elements: 10,12,5,4,20,8,7,15,13
12) Create a Huffman tree with the following nodes arranged in a priority queue