Insemester - Data - Structures ( DSE-2155)
Insemester - Data - Structures ( DSE-2155)
Instructions to Candidates:
❖ Answer ALL the questions & missing data may be suitable assumed.
❖ All the questions are compulsory.
❖ Write the answers neatly and legibly.
❖
a) Explain how to implement two stacks in one array A[1..N] in such a way that
neither stack overflows unless the total number of elements in both stacks
together is N.
b) Construct a binary tree given its inorder and postorder sequence as
1 16, 47, 54, 57, 61, 77, 90, 91, 95 and 16, 47, 57, 61, 54, 90, 95, 91,77 4
respectively. Also write the preorder traversal sequence for the constructed
binary tree.
c) Write the steps in detail for constructing a binary tree from the given inorder
and postorder sequence.
Construct max heap with the given set of values: 30, 55, 50, 45, 25, 65, 60,40.
2 Write all the intermediate steps in detail with formula along with the intermediate tree 4
representations.
a) Construct an expression tree for the given expression:
A + B - C * D / E + F + G * H.
3 Show each step of construction and also write the rules of construction in detail. 3
b) Give the outputs when you apply preorder, inorder and postorder traversals for
the constructed tree.
a) Construct a binary search tree by inserting the following integers in the given
order: 20, 13, 62, 4, 12 , 46, 97, 6, 8, 42, 60, 20, 3, 1. Show each step of
construction. Also write the rules for constructing a binary search tree.
4 3
b) From the constructed tree, delete the node 4 , then insert new node 10 followed
by deletion operation of internal node 8. Show all the intermediate tree
representations.
Draw the recursive tree for the Towers of Hanoi problem where the number of the
5 disks is four. The function call is towers(4,A,C,B) where 4=no.of disks, A=Source, 3
C=destination, B=auxillary at the initial step.
Page 1 of 2
Mention all the moves from the constructed tree.
a) Write the steps and code snippet for inerting a new node 22 in between 20 and
25 of the given Doubly linked list:
15<-> 20<->25<->30<->42.
6 3
b) Write the polish form of the given infix expression using standard algorithm.
(a+(b*(c-d)+(e)-(f*g)))
Write all the intermediate steps and show the stack content at each step.
Page 2 of 2