Please visit, subscribe and share 10 Minutes Lectures in Computer Science

# Data structures and algorithms multiple choice questions with answers, important interview questions in data structures, data structures questions for entrance exams

## SET 02

1. Which of the following represents the efficiency of the insertion sort?

(a) O(1)

(b) O(log n)

(c) O(n)

(d) O(n2)

2. What is the worst case running time of the following pseudo code in Big-O notation?

void fn(int n) {

int x = 0;

for (int i = 1; i < Math.pow(2, n); i *= 2) {

if (i < 10000000) {

for (int j = 0; j < Math.pow(2, i); j++) {

x++;

}

} else {

for (int k = 1; k < n; k *= 2) {

x--;

}

}

}

print ("Completed");

}

(a) O(n)

(b) O(n2)

(c) O(n log n)

(d) O(n2)

3. What is the best case running time of finding and removing the largest item in a binary search tree containing N elements?

(a) O(n)

(b) O(1)

(c) O(n log n)

(d) O(n2)

4. Which of the options is the running time of the following pseudo code?

public static int f4(int N) {

if (N == 0) return 0;

return f4(N/2) + f1(N) + f4(N/2);

}

(a) N

(b) log N

(c) n log n

(d) n2

5. Which of the following is correct about the statement “f(n) is O(f(n)2)”?

(a) The statement is always true

(b) The statement is sometimes true

(c) The statement is never true

(d) Not applicable

6. Given M=7 and L=11, what is the minimum number of leaf nodes in a B-Tree of height 5? [Note: M – maximum number of pointers in internal node, L – maximum number of data items in leaf node]

(a) 5

(b) 11

(c) 256

(d) 512

7. Which of the following is not a dynamic data structure?

(b) Stack.

(c) Array.

(d) Binary tree.

8. For the code fragment, find the best matching order of growth of running time;

int x = 1, i, j;

for (i = 0; i < N; i ++)

for (j = 1; j < R; j ++)

x = x * j;

(a) N log N

(b) R+N

(c) RN

(d) N(N+R)

9. What is the worst case running time of the following pseudo code in Big-O notation?

int snow(int n, int ball) {

if (n < 200) {

return n / 2;

} else if (n < 3000) {

for (int i = 0; i < n * n; i++) {

ball++;

}

return ball;

}

ball += snow(n / 2, ball);

return n * snow(n / 2, ball);

}

(a) O(n)

(b) O(n2)

(c) O(n log n)

(d) O(n2)

10. In general, linked lists allow which among the following?

(a) Insertions and removals anywhere.

(b) Insertions and removals only at one end.

(c) Insertions at the back and removals from the front.

(d) None of the above.

1 – (d), 2 – (c), 3 – (b), 4 – (c), 5 – (a), 6 – (d), 7 – (c), 8 – (c), 9 – (a), 10 – (a)

*************************

## Featured Content

### Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

data recovery