Data Structures and Algorithms - B.Tech 3rd Semester Exam., 2020 (New Course)
Data Structures 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.
-
Which of the following is time complexity of the given code?
\( int\ a=0; \)
\( for(i=0; i< N; i++) \{ \)
\( \quad for(j=N; j>i; j--) \{ \)
\( \quad \quad a = a + i + j; \)
\( \quad \} \)
\( \} \) -
Which of the following is time complexity of the given code?
\( int\ i,\ j,\ k=0; \)
\( for(i=n/2; i<=n; i++) \{ \)
\( \quad for(j=2; j<=n; j=j*2) \{ \)
\( \quad \quad k = k + n/2; \)
\( \quad \} \)
\( \} \) -
Which of the following cases does not exist in complexity theory?
-
The operation of processing each element in the list is known as
-
Arrays are best data structures
-
Each array declaration needs not give, implicitly or explicitly the information about
-
In general, the binary search method needs not more than
-
State True or False:
A. Binary search is used for searching in a sorted array.
B. The time complexity of binary search is O(logn). -
Which of the following is non-linear data structure?
-
Which is the correct output for the following sequence of operations? push(5), push(8), pop, push(2), push(5), pop, pop, pop, push(1), pop
-
Analyse the time complexity of the given function and also write the recurrence relation of the function:
\( int\ DoSomething(int\ n) \{ \)
\( \quad if(n<=2)\ return\ 1; \)
\( \quad else\ return\ (DoSomething(floor(sqrt(n))) + n); \)
\( \} \)
-
Consider the following postfix expression : 873-/6254+*+-
The above expression is evaluated using stack. Show the content of stack after each step.
-
What are the different notations for comparing the time complexity of an algorithm? Explain each of them with neat figures.
-
Explain the queue and circular queue with examples. Also, write the differences between the two.
-
Let a and b be positive integers. Suppose a function F is defined recursively as follows:
\( F(a,b) = \begin{cases} 0 & \text{if } a < b \\ F(a-b,b) + 1 & \text{if } b \le a \end{cases} \)
Find the values of the following: (a) \( F(2,3) \) (b) \( F(14,3) \)
-
Write the algorithm of prefix evaluation with example.
-
Write prefix notation of the following infix notation: \( A+B*C+D \)
-
What do you mean by ADT? Explain the ADT stack with test cases for both pop and push.
-
Hashing
-
Circular linked list
-
Adjacency list
-
AVL tree