Data Structure and Algorithms - B.Tech. 3rd Semester Examination, 2023
Data Structure and Algorithms
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
-
What is the time complexity of the following code snippet?
for(i=0; i<n; i++) { for(j=0; j<i; j++) { int sum = i + j; } } -
Which type of traversal of binary search tree outputs the value in sorted order?
-
Suppose a circular queue of capacity \( (n-1) \) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR=FRONT=0. The conditions to detect queue full and queue empty are
-
Which of the following data structures can be used for parentheses matching?
-
What is the worst-case time complexity of inserting n elements into an empty linked list, if the linked list needs to be maintained in sorted order?
-
What will be the postfix expression for the given infix expression: \( (a+b)*c-d \)
-
What is the outcome of the prefix expression + - * 3 2 / 8 4 1 ?
-
Where will the new element be inserted in the linked list implementation of the queue?
-
Let us consider a list of numbers (34, 16, 2, 93, 80, 77, 51) and a hash table size of 10. What is the order of elements (from index 0 to size-1) in the hash table?
-
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:
-
Why do we need an asymptotic notation? Explain the different asymptotic notations with definitions and examples.
-
Write the worst-case run time complexity of the following algorithms: linear search, bubble sort, merge sort, and push operation in the stack.
-
Write push() and pop() functions of a stack.
-
Evaluate the following postfix expression using STACK. Show all the steps. 8, 2, /, 3, *, 4, -, 6, 2, /, +
-
Write the algorithm to count the total elements in a singly linked list.
-
How a doubly linked list is better than a singly linked list? Explain deletion on a doubly linked list using an example.
-
The following values are to be stored in a hash table: 25, 42, 96, 101, 102, 162, 197. Describe how the values are hashed by using the division method of hashing with a table size of 7. Use chaining as the method of collision resolution.
-
Apply the merge sort on the following numbers: 10, 15, 50, 17, 20, 25, 30, 16, 70, 6.
-
Differentiate between stack and queue. Explain different types of queues with examples.
-
Write the properties of a binary search tree. Create a binary search tree using the following elements: 45, 15, 79, 90, 10, 55, 12, 20, 50.
-
Consider the in-order and pre-order traversal of a binary search tree are (1, 2, 3, 4, 5, 6, 8, 10, 25) and (4, 3, 1, 2, 10, 8, 5, 6, 25) respectively. Construct a unique binary search tree for the given in-order and pre-order traversals.
-
Explain the insertion in the AVL tree using an example.
-
Explain the Heap sort algorithm. Create a heap for the following elements and then sort them: 13, 102, 405, 136, 15, 105, 390, 432, 28, 444.