Data Structures - Scheme s3 Cs B.tech May 2019
Data Structures - Scheme s3 Cs B.tech May 2019
PART B
Answer any two full questions, each carries9 marks.
5 a) Definition – 1 mark
Essential properties –
must have a base case which can be solved without
recursion
recursive call should progress towards base case
– 3 marks (4)
b) Recursive function - 4 marks
Time Complexity – O(n) - 1 mark (5)
6 (i) Algorithm to insert a node with data ‘y’ after a node whose data is ‘x’. (3)
(ii) Algorithm to delete a node whose data is ‘s’ . (3)
(iii) Algorithm to insert a node with data ‘a’ as the 1st node of the list. (3)
7 a) explanation (3)
b) Algorithm (6)
PART C
Answer all questions, each carries3 marks.
8 Algorithm (3)
9 Disadvantages-
Queue full condition does not necessarily mean that the queue is full – 1 mark
Overcome –
After each Enqueue operation, shift the elements towards front (or)
Treat the queue as circular – 2 marks (3)
10 Definition of Tree – 1.5 marks ; Definition of Binary Tree – 1.5 marks (3)
11 Diagram (3)
PART D
Answer any two full questions, each carries9 marks.
12 a) BST definition 1 mark
Example 2 marks (3)
14 a) Algorithm (4)
b) Iterative/Non Recursive algorithm for Inorder Traversal of a Binary Tree (5)
PART E
Answer any four full questions, each carries10 marks.
15 a) (i) Adjacency Matrix with advantages and disadvantages – 3 marks
(ii) Adjacency List with advantages and disadvantages – 3 marks (6)
b) Algorithm (4)
16 a) Algorithm for DFS – 3 marks; Algorithm for BFS – 3 marks (6)
b) Output of DFS traversal – 2 marks; Output of BFS traversal – 2 marks; (4)
17 a) Algorithm for Quick Sort (5)
b) Trace the working showing the partitioned array after each call. (5)
18 a) Comparison listing atleast 3 differences (3)
b) Algorithm - 4 marks
Trace the algorithm on given input (show the values of beg, end and mid after
each iteration) – 3 marks (7)
19 a) Collision – 1 mark; Example – 1 mark (2)
b) Division Method with an example – 2marks
Midsquare Method with an example – 2marks
Folding Method with an example – 2marks
Digit Analysis Method with an example – 2marks (8)
20 h(x) = x mod 7
2341 mod 7 = 3
4234 mod 7 = 6
2839 mod 7 = 4
430 mod 7 = 3
22 mod 7 =1
397 mod 7 = 5
3920 mod 7 = 0 - 2 marks
(i) Separate Chaining
0 [3920] 1 [22] 2 [ ] 3 [2341, 430] 4 [2839] 5 [397] 6 [4234] - 2 marks
(ii) Linear probing
0 [397] 1 [22] 2 [3920] 3 [2341] 4 [2839] 5 [430] 6 [4234] - 2 marks
(iii) quadriatic probing
0 [430] 1 [22] 2 [3920] 3 [2341] 4 [2839] 5 [397] 6 [4234] - 4 marks
430 collides at 3:
3+12 = 4
3+22 = 3+4 = 7 % 7 = 0
3920 collides at 0:
0+12 = 1
0+22 = 0+4 = 4
0+32 = 0+9 = 9 % 7 = 2
(students are supposed to show the output by drawing the hash table) (10)
****