New Tutorials: # Data Structure and Algo Questions

This Test will cover basic concepts of data Structure and related algorithm.

Q. N queens puzzle problem is a typical implementation of which of the following algorithm?
 A. Dynamic Programming B. Greedy Approach C. Backtracking D. Divide and conquer
Q. What is the time complexity required to sort the below list of elements using quick sort?
 0 0 0 0 0 0 0 0 0
 A. O(n2) B. O(n log n) C. O(1) D. O(log n)
Q. What is the total number of subsequences possible for the string "STUDY_TONIGHT"?
 A. 8192 B. 1024 C. 4096 D. 512

Q. What is the time complexity of finding minimum number of matrix multiplications required for a given sequence of matrices using dynamic programming?
 A. O(n) B. O(n2) C. O(n3) D. O(n4)
Q. What is the number of ways in which three matrices A1, A2, A3 and A4 can be multiplied?
Sizes:
A1 = 10 X 20
A2 = 20 X 15
A3 = 15 X20
A4 = 20 X 20
 A. 14 ways B. 5 ways C. 3 ways D. 12 ways
Q. Complete the following psudo code for generating Fibonacci Series:
``` ```
f()
{
if(n==0)
return 0;
if(n==1)
return 1;
return (__________);
```
```
 A. f(n-1) + f(n-2) B. f(n+1) + f(n+2) C. f(n-1) - f(n-2) D. f(n+1) - f(n+2)
Q. Consider the following recurrence relation to generate Fibonacci series:
f(n) = f(n-1) + f(n-2), when n >= 2
f(n) = 1, when n=1
f(n) = 0, when n=0
What is the total number of function calls when F(5) is called?
\
 A. 10 B. 11 C. 14 D. 15
Q. What is the time complexity to find the minimum element in min heap?
 A. O(nlog n) B. O(n) C. O(log n) D. O(1)

Q. What is the time complexity of an algorithm whose recurrence relation is given below:
T(n) = 8 T(n/3) + n2
 A. Theta(n log n) B. Theta(n2) C. O(1) D. O(log n)
Q. What is the space complexity of the below psudo code?
``` ```
F(Arr[], 1, n)
{
int I;
Create B[n];
For(i=1 to n)
B[i] = Arr[i];
}
```
```
 A. O(n) B. O(n2) C. O(log n) D. O(1)
Q. What is the total number of comparisons and movement required in the worst case of insertion sort to sort n elements?
 A. N comparisons + N movements B. N-1 comparisons + N movements C. N-1 comparisons + N-1 movements D. N comparisons + N-1 movements
Q. What is the maximum numbers of nodes present in complete binary tree?
 A. 2h+1 -1 B. 2h+1 +1 C. 2h+1 D. 2h-1 -1

Q. What is the expected result after first two passes of bubble sort(consider worst case possible) ?
 A. Largest two elements will be present at their sorted positions B. At least two elements will be present at their sorted positions C. At most two elements will be present at their sorted positions D. None of the above
Q. What is the output of the following code?
``````
void main()
{
string str[] = "Study_tonight";
printf("%d", sizeof(str));
printf("%d", strlen(str));
}
```
```
 A. 13 13 B. 14 1 3 C. 13 14 D. 14 14
Q. Which of the following is the best choice for Hashing when we want to perform deletion operations on elements?