nit data structure
nit data structure
:
Name of student .
Y\ L.---1/4,
National Ins ute of Technology Hamirpur
Department of Computer Science & Engineering
End-Semester Exam Nov-2023
Q I . What is the limitation of linear queue? Why circular queue is needed? Explain with proper
[7 Marks]
example using insertion and deletion operation.
Q2. Describe merge sort algorithm with suitable example (using input array 1, 15, 24, 26, 2, 13,
[7 Marks]
27, 38). Also, give the worst time complexity analysis of the algorithm.
Q3. (a) What is hashing? What is collision? Flow collisions can be handled. Using the hash
function 'key mod 7', insert the following sequence of keys in the hash table- [7 Marks]
50, 700, 76, 85, 92, 73 and 101
Use linear and quadric probing techniques for collision resolution.
(b) Insert the keys 79, 69, 98, 72, 14, 50 into the Hash Table of size 13. Resolve all collisions
using Double Hashing where first hash-function is hi (k) = k mod 13 and second hash-
function is h2 (k) = 1 + mod 11).
Q4. Explain heapsort algorithm with its time and space complexity. Apply heapsort for following
I6, 14, I0, 8, 7, 9, 3, 2, 4. I }. [7 Marks]
input array A,-
Q5. Explain Depth first search graph traversal technique with its algorithm, time complexity using
[7 Marks]
following graph.
Q6. What is the limitation of Binary Search Tree explain with example. Explain how AVL tree
overcome this limitation. Construct AVL Tree for the following sequence of numbers-
50, 20 , 60 , 10 , 8 , 15 , 32 46 , 11 48 [7 Marks]
Q7. (a) The postorder traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1. The inorder traversal of
the same tree is 8, 6, 9, 4, 7, 2, 5, I , 3. Construct a binary tree from postorder and inorder
traversal and calculate the height of the binary tree. [34-1+1+3=8 Marks]
(b) How many at least and at most number of elements is in a binary tree of height h, h >= 0?
(c) What is the at least and at most height of a binary tree that contains n elements, n >= 0?
(d) What is the time complexity of the following program? Explain your answer.
void fun (int n)
if(n<l)
return;
else
fun(n-1);
printf(''Yod", n);