You are on page 1of 2

PDPM Indian Institute of Information Technology, Design and manufacturing Jabalpur

Data structure and Algorithm (ES 103)


Full marks 40 End Term Time 3 Hours

Q. Question Marks
No.
1 A. Let a and b denotes positive integers. Suppose a function Q is defined recursively as follows 2
fO if a < b
QCa,b) = lQCa - b,b) + 1 if b ~ a
a) Find the value ofQ(2, 3) and Q(14, 3) b) What does this function do? Find Q(586!, 7)

B. What is the complexity of L:i:llog i

2 A. Following is a pseudo code of a series of operation on a stack S. PUSH (S, X) pushes an element X into S, 9
POpeS, X) pops out an element from stack S as X, PRINT(X) display the variable X and EMPTYST ACK
(S) is a Boolean function which returns true if S is empty and false otherwise. What is the output of the
code?
1 X: = 30 2. Y: = 15; 3. Z: = 20 4. PUSH (S, X); 5. PUSHeS. 40);
6. popes, Z) 7. PUSH (S, Y) 8. PUSHeS, 30) 9. PUSHeS, Z) 10. Popes. X)
11. PUSHeS, 20) 12 PUSHeS, X) 13 while not EMPTYST ACK(S) do
14 POpeS, X) 15 PRINT (X) 16 END

B. Make use of the infix and postfix expression given below to trace the corresponding expression tree.
Infix: A +B* C/ FT H
Postfix: A B C * F H T / +

C. Write a function which will split a circularly linked list P with n nodes into two circularly linked list A
and B with the first In/2J and the last nodes n - In/2J of the list P in them, respectively.

D. Given a sorted array, write a function for converting the array to balanced binary search tree.

3 A. When is the sorting process said to be stable? Test for the stability of heap sort on the list L = {71, 72, 4
73 }.
B. What are the minimum and maximum number of elements in a heap of height h?

C. Assume a chained hash table in which each of the chain is implemented as a binary search tree rather than
a singly linked list. Build such a hash table for the key {9, 10,6,20, 14, 16,5,40,4,2, 7, 3, 8} using hash
function H(X) = X mod 5 where X is the key. What are the advantage of adopting this system.

4 A. Write a function to check whether the given binary tree is BST or not. 12

B. Write a function for deleting the ilh indexed element in a given min heap.

C. For the A VL tree below, what is the result A VL tree after we remove the element A, L, G, 0, R, I.

C. What is the minimum and maximum number of nodes in an A VL tree of height h? Justify your answer.

D. Given the following B-tree of order m = 4, show each corresponding B-tree after deleting 6, 13, 7, 2, 4
in the se uence.
5 A. Write a function to count the number of connected components of Graph G which is represented in the 13
adjacent matrix.

B. What is the number of distinct unordered pairs with (u, v) , u i- v in a graph with n vertices.

C. Extract a minimum cost spanning tree for the given graph.

D. Run the Bellman-Ford algorithm on the weighted, directed graph of the shown figure. Start at vertex s.

E. Use Dijkstra's algorithm to find the cost of the cheapest path between a and _ in
the following weighted graph.?

a z

F. Given a graph G = (V, E) with positive edge weights, the Bellman-Ford algorithm and Dijkstra's
algorithm can produce different shortest-path trees despite always producing the same shortest-path
weights. Justify your answer and also Write down the difference between Bellman-Ford and Dijkstra's
algorithms.

G. If we modify the RELAX portion of the Bellman-Ford algorithm so that it updates d [v] and rr[ v] if
d [ v] 2: d [ u] + w (u, v) (instead of doing so only if d [v] is strictly greater than d [u] +
w (u, v), does the resulting algorithm still produce correct shortest-path weights and a correct shortest-
ath tree? Justi our answer.

You might also like