DSA PYQ
DSA PYQ
a. What do you understand by time space trade off? Explain best, worst and average case
analysis in this respect with an example
b. Use quick sort algorithm to sort 15,22,30,10,15,64,1,3,9,2. Is it a stable sorting
algorithm? – Justify.
c. Define spanning tree. Also construct minimum spanning tree using prim’s algorithm for
the given graph.
d. Define tree, binary tree, complete binary tree and full binary tree. Write algorithms or
function to obtain traversals of a binary tree in preorder, postorder and inorder.
e. Construct a B-tree on following sequence of inputs.
10, 20, 30, 40, 50, 60, 70, 80, 90
Assume that the order of the B-tree is 3.
SECTION C
1|Page
2|Page
Printed Page: 1 of 2
Subject Code: KCS301
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
B. TECH
(SEM III) THEORY EXAMINATION 2020-21
DATA STRUCTURES
Time: 3 Hours Total Marks: 100
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
P
0Q
1
13
h. Write short notes on adjacency multi list representation a Graph. 2 4
29
2.
0E
24
P2
5.
_Q
.5
SECTION B 17
TU
16
order and column major order. Assume the first element is stored
:4
exponent operator.
ar
c. Explain any three commonly used hash function with the suitable 10 3
example? A hash function H defined as H(key) =key%7, with linear
M
indexed from 0 to 6. what will be the location of key 11? Justify your
|2
1|Page
AKTU_QP20E290QP | 22-Mar-2021 13:42:16 | 117.55.242.131
Downloaded by Hitesh Bajpai (2k23.it1a.2313702@gmail.com)
lOMoARcPSD|50958543
Printed Page: 2 of 2
Subject Code: KCS301
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
SECTION C
3. Attempt any one part of the following:
Q no. Question Marks CO
a. Consider the two dimensional lower triangular matrix (LTM) of order 10 1
N ,Obtain the formula for address calculation in the address of row
major and column major order for location LTM[j][k], if base address
is BA and space occupied by each element is w byte.
b. Write a C program to insert a node at kth position in single linked list. 10 1
P
0Q
5. Attempt any one part of the following:
1
13
29
2.
a. Write an algorithm for merge sort and apply on following elements 10 3
0E
24
45,32,65,76,23,12,54,67,22,87.
P2
5.
_Q
.5
17
6. Attempt any one part of the following:
TU
|1
a. Describe Prim`s algorithm and find the cost of minimum spanning tree 10 4
16
2|Page
AKTU_QP20E290QP | 22-Mar-2021 13:42:16 | 117.55.242.131
Downloaded by Hitesh Bajpai (2k23.it1a.2313702@gmail.com)
lOMoARcPSD|50958543
Printed Page: 1 of 2
Subject Code: KCS301
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2021-22
DATA STRUCTURE
1
(f) List the advantages of doubly linked list over single linked list. 1
13
0
29
(g) Give example of one each stable and unstable sorting techniques. 2
2.
(h) Write advantages of AVL tree over Binary Search Tree (BST) 3
2_
24
(i) What is tail recursion? Explain with a suitable example. 4
2P
5.
(j) Write different representations of graphs in the memory. 5
.5
P2
SECTION B 17
2. Attempt any three of the following: 10X3 = 30
Q
Q No Questions CO
|1
(a) Write advantages and disadvantages of linked list over arrays. Write a 'C' function 1
creating new linear linked list by selecting alternate elements of a linear linked list.
49
(b) Write algorithms of insertion sort. Implement the same on the following numbers; 2
8:
also calculate its time complexity. 13, 16, 10, 11, 4, 12, 6, 7
(c) Differentiate between DFS and BFS. Draw the breadth First Tree for the above 3
:2
graph.
13
2
02
-2
ar
M
9-
(d) Differentiate between liner and binary search algorithm. Write a recursive function 4
to implement binary search.
|2
(e) What is the significance of maintaining threads in Binary Search Tree? Write an 5
algorithm to insert a node in thread binary tree.
SECTION C
3. Attempt any one part of the following: 10X1 = 10
Q No Questions CO
(a) Suppose a three dimensional array A is declared using A[1:10, -5:5, -10:5) 1
(i) Find the length of each dimension and the number of elements in A
(ii) Explain Row major order and Column Major Order in detail with explanation
formula expression.
Printed Page: 2 of 2
Subject Code: KCS301
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2021-22
DATA STRUCTURE
(b) Discuss the representation of polynomial of single variable using linked list. Write 1
'C' functions to add two such polynomials represented by linked list.
4. Attempt any one part of the following: 10 X1 = 10
Q No Questions CO
(a) (i) Use the merge sort algorithm to sort the following elements in ascending order. 2
13, 16, 10, 11, 4, 12, 6, 7.
What is the time and space complexity of merge sort?
(ii) Use quick sort algorithm to sort 15,22,30,10,15,64,1,3,9,2. Is it a stable sorting
algorithm? Justify.
(b) (i) The keys 12, 17, 13, 2, 5, 43, 5 and 15 are inserted into an initially empty hash 2
table of length 15 using open addressing with hash function h(k) = k mod 10 and
linear probing. What is the resultant hash table?
(ii) Differentiae between linear and quadratic probing techniques.
5. Attempt any one part of the following: 10X1 = 10
Q No Questions CO
(a) Use Dijkstra’s algorithm to find the shortest paths from source to all other vertices in 3
the following graph.
1
13
0
29
2.
2_
24
2P
5.
(b) Apply Prim’s algorithm to find a minimum spanning tree in the following weighted 3
.5
graph as shown below.
P2
17
Q
|1
49
8:
:2
13
Q No Questions CO
02
(a) (i) Write an iterative function to search a key in Binary Search Tree (BST). 4
-2
recursive functions.
9-
(a) (i) Why does time complexity of search operation in B-Tree is better than Binary 5
Search Tree (BST)?
(ii) Insert the following keys into an initially empty B-tree of order 5
a, g, f, b, k, d, h, m, j, e, s, i, r, x, c, l, n, t, u, p
(iii) What will be the resultant B-Tree after deleting keys j, t and d in sequence?
(b) (i) Design a method for keeping two stacks within a single linear array so that 5
neither stack overflow until all the memory is used.
(ii) Write a C program to reverse a string using stack.
B. TECH.
(SEM III) THEORY EXAMINATION 2022-23
DATA STRUCTURE
Time: 3 Hours Total Marks: 100
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
2
90
of complete binary tree.
13
(j) Which data structure is used to perform recursion and why?
_2
2.
SECTION B
P2
24
2. Attempt any three of the following: 10x3=30
5.
3D
.5
P2
|1
(ii) Find the address of element Y (2, 2, 3), assuming Base address of Y = 400
and each element occupies 4 memory locations.
6
:3
(b) What is Stack? Write a C program for linked list implementation of stack.
9
(c) Write an algorithm for Quick sort. Use Quick sort algorithm to sort the following
:2
elements: 2, 8, 7, 1, 3, 5, 6, 4
13
(d) Write the Dijkstra algorithm for shortest path in a graph and also find the shortest path
from ‘S’ to all remaining vertices of graph in the following graph:
3
02
-2
03
7-
|2
(e) The order of nodes of a binary tree in inorder and postorder traversal are as follows:
In order : B, I, D, A, C, G, E, H, F.
Post order: I, D, B, G, C, H, F, E, A.
(i) Draw the corresponding binary tree.
(ii) Write the pre order traversal of the same tree.
SECTION C
3. Attempt any one part of the following: 10x1=10
(a) How to represent the polynomial using linked list ? Write a C program to add two
polynomials using linked list.
(b) Discuss doubly linked list. Write an algorithm to insert a node after a given node
in singly linked list.
4. Attempt any one part of the following: 10x1=10
(a) Write an algorithm for converting infix expression into postfix expression. Trace
your algorithm for infix expression Q into its equivalent postfix expression P,
Q: A + ( B * C – ( D / E ^ F) * G ) * H
(b) What is circular Queue? Write a C code to insert an element in circular queue?
5. Attempt any one part of the following: 10x1=10
(a) What is Hashing? Explain division method to compute the hash function and also
explain the collision resolution strategies used in hashing.
(b) Write an algorithm for Heap Sort. Use Heap sort algorithm, sort the following
sequence:
18, 25, 45, 34, 36, 51, 43, and 24.
6. Attempt any one part of the following: 10x1=10
(a) What is spanning tree? Write down the Prim’s algorithm to obtain minimum cost
2
90
spanning tree. Use Prim’s algorithm to find the minimum cost spanning tree
13
in the following graph:
_2
2.
P2
24
5.
3D
.5
P2
17
Q
|1
(b) Write and explain the Floyd Warshall algorithm to find the all pair shortest path. Use the
6
BTECH
(SEM III) THEORY EXAMINATION 2023-24
DATA STRUCTURE
TIME: 3HRS M.MARKS: 70
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
2
13
a. Write a Pseudo code that will concatenate two linked lists. Function should 7 1
_2
2.
have two parameters, pointers to the beginning of the lists and the function
P2
24
b. Write an algorithm to convert a valid arithmetic infix expression into an 7 2
4D
5.
equivalent postfix expression. Trace your algorithm for following infix
.5
P2
expression.
17
A+B*C-D/F
Q
|1
e. Consider the following graph and using Dijkstra Algorithm find the shortest 7 5
path.
:2
13
4
02
-2
03
6-
|1
SECTION C
3. Attempt any one part of the following: 7x1=7
a. Each element of an array Data [20][50] requires 4 bytes of storage. Base 7 1
address of Data is 2000. Determine the location of Data [10][10] when the
array is stored as:
(i) Row major
(ii) Column major
1|Page
QP24DP2_290 | 16-03-2024 13:20:56 | 117.55.242.132
Downloaded by Hitesh Bajpai (2k23.it1a.2313702@gmail.com)
Printed Page: 2 of 2
lOMoARcPSD|50958543
BTECH
(SEM III) THEORY EXAMINATION 2023-24
DATA STRUCTURE
TIME: 3HRS M.MARKS: 70
b. How will you create link list representation of a polynomial. Explain it with 7 1
the suitable example.
4. Attempt any one part of the following: 7x1=7
a. Write an algorithm to evaluate an arithmetic expression using stack and show 7 2
how the expression 3*(5-3) will be evaluate.
b. A double ended Queue (deque) is a linear list in which additions may be made 7 2
at either end. Obtain a data representation mapping a deque into one
dimensional array. Write C function to add and delete elements from either
end of deque.
5. Attempt any one part of the following: 7x1=7
a. Write a C program for sorting 100 integer numbers wring selection sort 7 3
procedure. Discuss the worst-case time complexity of the algorithms.
b. Write a program in C language to implement binary search algorithm. Also 7 3
discuss the average behavior of the algorithm.
6. Attempt any one part of the following: 7x1=7
a. If E and I denotes the external and internal path length of a binary tree having 7 4
90
2
13
n internal nodes then show that E=I+2n.
_2
b. Suppose character a, b, c, d,e,f has probabilities 0.07, 0.09, 0.12, 0.22, 0.23, 7 4
2.
P2
0.27 respectively. Find an optional Huffman code and draw the Huffman tree.
24
What is the average code length?
4D
5.
7. Attempt any one part of the following: 7x1=7
.5
P2
a. Find the minimum spanning tree using Prim’s algorithm for the graph shown 7 5
17
below: -
Q
|1
56
0:
:2
13
4
02
adjacency matrix.
6-
|1
2|Page
QP24DP2_290 | 16-03-2024 13:20:56 | 117.55.242.132
Downloaded by Hitesh Bajpai (2k23.it1a.2313702@gmail.com)