DS Endsem 2023nov
DS Endsem 2023nov
Instructions to Candidates:
Answer ALL questions.
Missing data may be suitably assumed.
1 Imagine a scenario where you are an urban planner tasked with optimizing the 5 CO4 BL4 PO1,2,3
construction of roads to connect several neighbourhoods in a growing city.
Each neighbourhood represents a vertex in a graph, and the roads between
them have different associated costs.
Let's consider a city with 7 neighborhoods (A, B, C, D, E, F, G) and their
associated road construction costs:
Table :-1
Source Destination Costs($)
A B 4
A C 7
A E 3
A F 6
B C 8
B D 9
C D 10
C E 5
D E 6
D F 11
E F 12
E G 5
F G 10
Your goal is to minimize the overall cost of constructing roads while ensuring
that all neighborhoods are interconnected.
i) Describe how you would apply the principles of a minimum
spanning tree using Kruskal’s algorithm to efficiently plan the road
network for the city.
ii) Find the cost of construction.
2 i) Construct the binary search tree and threaded tree for the given 3 CO3 BL3 PO1,2,3
data:
BRAINCOMPUTERINTERFACE
ii) How many null pointers are present in each representation?
3 Consider the scenario: Joe is having three descendants Alo, Rio, Sang. Rio 2 CO3 BL3 PO1,2,3
have two descendants Mark and Mary. Represent this data using tree data
structure. Convert this tree into binary tree. Show each step with neat diagram.
4 Consider the scenario wherein there is a need to process a large dataset of 5 CO4 BL4 PO1,2,3
student records for a university admission system. The dataset consists of
various student attributes such as Student ID and test scores. Sort this dataset
given below in Table 1 in descending order based on a specific attribute, say
the students' test scores, to streamline the admission process.
Table :-1
Student 101 102 103 104 105 106 107 108 109 110
ID
Test 85 72 91 68 77 94 80 63 88 75
score
i) Explain how you would use the heap sort algorithm to efficiently
sort the student records based on their test scores.
ii) Discuss the step-by-step process of heap sort and how it could be
applied to sort the student records. Write all intermediate steps in
detail with formula along with the intermediate tree and array
representation.
5 Construct a binary tree from the given preorder traversal as 3 CO2 BL3 PO1,2,3
CABDIHKMEFGJLNO and inorder traversal as AIDBKHMCFEJNLOG.
i) Draw the tree with all intermediate steps.
ii) Write its postorder traversal.
6 If the values of A, B, C, and D are 2, 3, 4, and 5 respectively, calculate the 2 CO2 BL3 PO1,2,3
value of the following prefix and postfix expressions:
i) +–*ABCD
ii) AB*C–D+
7 Construct a B tree (right biased) of order 4 by inserting the following keys :- 5 CO4 BL4 PO1,2,3
OBJECTRINDPGAMQ
i) From the constructed tree, delete the following keys: B, D, A, R, J
one by one. Explain which type of target node is deleted and
mention which method is applied to solve the underflow of b-tree.
Write all the intermediate steps and tree representations for
insertion and deletion operations clearly and neatly.
ii) What is meant by reflow state in b-tree?
8 Write the pseudocode for Merge sort and trace the algorithm for the input: 3 CO1 BL3 PO1,2,3
100,90,80,70,60,50.
9 Write a recursive user defined function to find Fibonacci series of the number 2 CO1 BL2 PO1,2,3
n.
10 Draw the Recursive Tree for the Towers of Hanoi problem where the number 5 CO2 BL3 PO1,2,3
of the disks is four. The function call is towers (4, N, M, L,) where 4 = no.of
disks, N=Source, M=destination, L=Auxiliary at the initial step. Mention all
the moves from the constructed tree and find total no.of moves.
11 i) Construct an expression tree for the given expression: A+(B- 3 CO2 BL3 PO1,2,3
C*(D/E)+F+G)*H^K-L.
ii) Write the preorder and postorder traversal of the constructed tree.
12 What are the two ways of deleting a node from a binary search tree which 2 CO1 BL2 PO1,2,3
contains left and right subtree?
13 i) Write the standard algorithm steps for converting infix to Polish 5 CO3 BL3 PO1,2,3
expression.
ii) Convert the given expression into Polish notation using standard
algorithm.
A+B-(L^M)*(P+O)-Q/S^R*T+Z
Write all the intermediate steps, show the stack content and resultant
expression at each step .
14 Write the algorithm for performing enqueue and dequeue operation on circular 3 CO2 BL2 PO1,2,3
queue by considering all necessary conditions.
15 Compare and contrast singly and doubly linked list. 2 CO2 BL1 PO1,2,3