2022 Dsa
2022 Dsa
2022 Dsa
SECTION – I
Q- 1 Answer the questions below.
(i) What is the complexity of running Quick sort on an array of size n, which is already [01]
sorted?
(ii) State True or False: In a linked list representation of the simple queue, insertion should [01]
be performed at end and deletion should be performed from beginning.
Q – 2(a) Convert the following expression into postfix form using stack: A*(B+C)*D-E. Evaluate [03]
the postfix form for A=4, B=8, C= (-2),D=3,E=9.
Q – 2(b) Answer the questions below. (Any Three) [12]
(i) Given code deletes the node which doesn't follow the ascending order sequence from this
linked list : 3>>>4>>>5>>>6>>>7>>>9>>>8>>>10.
Write the correct statements for a1,a2,a3,a4.
node structure is defined using this code:
struct node
{
int data;
struct node * link;
} *head, *p;
Code to remove node is::
struct node *C= head;
while(C->data <= a1)
{
p=a2;
C=a3;
} a4;
Page 1 of 4
Candidate Seat no………….
(ii) Explain the recursion stack for tower of Hanoi for number of discs=3.
(iii) Explain different cases of overflow condition for Circular Queue. Also mention the
condition to display the queue contents for every case.
(iv) Consider the structure to store the details of students who have registered for the Codechef
contest.
struct codechef_contest
{
int rollno;
char firstname[20];
char lastname[20];
};
Details are arranged in ascending order (not necessarily contiguous) by roll numbers.
Mention the efficient approach to change the last name of a student with any given roll
number. Show the steps with any example.
(iii) Consider the two sorted list T1: 5,8,11 and T2: 4,6,9,15,20,28. Write steps to merge the
T1 and T2 in ascending order.
(iv) Write steps to replace recursion with a stack, to find the factorial of number 6.
SECTION – II
Q- 4 Answer the questions below.
(i) What is the maximum number of edges in an acyclic undirected graph with n vertices? [01]
(ii) What is the maximum height of any AVL-tree with 12 nodes? [01]
(iii) A simple Graph has 24 edges and degree of each vertex is 4. Find the number of vertices. [01]
Page 2 of 4
Candidate Seat no………….
Q-5(a) Justify that hashing is an efficient searching method compared to Linear search and Binary [03]
search.
Q – 5(b) Answer the questions below. (Any Three) [12]
(i) The keys 22, 38, 33, 12, 3, 43, 15 and 85 are inserted into an initially empty hash table of
length 10 using open addressing with hash function h(k) = k mod 10 and linear probing.
What is the resultant hash table and number of collisions?
(ii) Show the adjacency matrix representation of the following graph. Find the in degree and
out degree of every node from adjacency matrix.
(iii) Apply Depth First traversal on following graph. Mention the sequence of each visited node
using stack. Assume that Starting vertex is A and visit the vertices in alphabetical order.
Page 3 of 4
Candidate Seat no………….
***
Page 4 of 4