Spring 23
Spring 23
(Any examinee found adopting unfair means will be expelled from the trimester /
program as per UIU disciplinary rules)
There are FOUR questions. Answer all of them. Figures in the right-hand margin
indicate full marks.
1. a) Convert the following infix expression into postfix using a STACK. [3]
Infix expression: a↑2-(b+c/d*a+b)
b) Evaluate the postfix expression, a b – c d * + for a=2, b=3, c=2 and d=1 using a [2]
STACK
c) Find a recursive algorithm for TOWER OF HANOI using one intermediate pillar/peg [3]
and show simulation for n = 3, where n is the number of disks.
b) Construct an Adjacency Marix and an Adjacency List for the graph in Ques. 2(a). [3]
Show the memory requirement for each of the cases.
d) Show the depth first search (DFS) sequence from the sparse graph of 2(c) assuming [2]
any one is the starting vertex.
e) Write an algorithm for Topological Sorting. Show the simulation of your algorithm [3]
using the graph in Ques. 2(a).
b) Traverse the binary tree of Ques. 3(a) using the preorder, inorder, postorder and level [3]
order techniques. Level each of the nodes of the tree. Also find the height of the tree
using level.
c) Show the status of a QUEUE and a Priority QUEUE (Data in descending Order) for [3]
the following operations, where both QUEUEs are implemented by an array of size,
m=3. Here, Enqueue and Dequeue mean insert and delete respectively
d) Sort the following data in descending order using the heapsort algorithm. [3]
10 18 17 20 15
1
4. a) Construct a binary search tree (BST) using the nodes [3]
10 20 30 40 50 60 70 80
Also show the insertion and deletion of 75 and 40, respectively in/from the BST.
b) Represent a binary tree using a one-dimensional array and a linked list. [2]
c) S1 = {10, 20, 30, 40} and S2= {50, 60, 70} are disjoint sets, where the maximum of [1]
both sets are the representatives. How can you check 10 and 50 are not in the same set?
d) Which Data Structures are appropriate to implement the following and why? [3]