Summer 22
Summer 22
(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) Draw a binary tree using the data given below, where x, y, z, p, r, t, u and v are nodes of the [1]
tree.
y p z x r t u v
Here, x=last two digits of your student id+5, y=x+3, z=x+y, p=y+z, r=x+2, t=p+r, u=600, v=700
b) Traverse the binary tree of Ques. 1(a) using the preorder, inorder, and postorder techniques. [4]
Level each of the nodes of the tree. Also find the height of the tree using level.
c) Draw a binary tree from the following Preorder and Inorder sequences [2]
Preorder: x y p r z t v u
Inorder: p y r x t v z u
Here, x=last two digits of your student id+5, y=x+3, z=x+y, p=y+z, r=x+2, t=p+r, u=600, v=700
d)Write an algorithm for the level order. Show the simulation for the tree in Ques. 1(a). [3]
2. a) Show the status of a QUEUE and a Priority QUEUE (Data in Ascending Order) for the [3]
following operations, where both QUEUEs are implemented by an array of size, m=3. Here,
Enqueue and Dequeue mean insert and delete respectively, and x=last two digits of your student
id+5, y=x+3, z=x+y and p=y+z.
Enqueue(z), Enqueue(p), Dequeue(), Enqueue(y), Enqueue(z), Dequeue()
b) Draw a complete binary tree and then build the min-heap tree from the following [5]
data, where x= last two digits of your student id+150, y=x+130, and z=x+y. Finally, sort the data
in descending order using the heapsort algorithm.
10 x 20 z y 8
c) Two disjoint sets {y, p, z, x} and {r, t} are given, where maximum one of a set is the [2]
representative of that set. Determine UNION(Find(x), Find(t)). How can you check x and y are
in the same set using Find operation? Here, x=last two digits of your student id+9, y=x+3,
z=x+y, p=y+z, r=x+2, t=700.
3. a) Draw a directed acyclic graph using the vertices y, p, z, x, r and u, where x=last two digits of [1]
your student id+5, y=x+3, z=x+y, p=y+z, r=x+2, u=p+r
b) Construct an Adjacency Marix and an Adjacency List for the graph in Ques. 3(a). [3]
c) Write an algorithm for Topological Sorting. Show the simulation of your algorithm using the [4]
graph in Ques. 3(a).
d) Draw a sparse and a dense graph using the vertices y, p, z, x, and r, where x=last two digits of [2]
your student id+5, y=x+3, z=x+y, p=y+z, r=x+2
1
4. a) Draw an undirected graph using the vertices y, p, z, x and r, where x=last two digits of your [2]
student id+5, y=x+3, z=x+y, p=y+z, r=x+2. Also find the Depth First Search (DFS) sequence
from the graph considering x is the starting vertex.
b) Construct a binary search tree (BST) using the nodes y, p, z, x, r and t, where x=last two [3]
digits of your student id+5, y=x+3, z=x+y, p=y+z, r=x+2, t=900. Show the insertion and
deletion of p+r and z, respectively in/from the BST.
c) Write an algorithm to display all the elements stored in a QUEUE implemented by an array. [2]
d) Which Data Structures are appropriate to implement the following and why?
[3]
i) Different areas of Dhaka City with distances
ii) Line in front of a Lift
iii) Binary Tree Construction