Monday, 1 June 2020

Data structures and algorithms MCQ with answers 01

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


Data Structures and Algorithms Multiple Choice Questions

SET 01

1. Suppose we sort an array of numbers, but it turns out every element of the array is the same, e.g., {20, 20, 20, ..., 20}. What is the asymptotic running time of insertion sort in this case?

(a) O(n)

(b) O(n2)

(c) O(n log n)

(d) O(n2)

 

2. Assume A is an array-based tree with 70 nodes. Which is the parent of A[50]?

(a) A[5]

(b) A[24]

(c) A[25]

(d) A[35]

 

3. Suppose we sort an array of numbers, but it turns out every element of the array is the same, e.g., {20, 20, 20, ..., 20}. What is the asymptotic running time of selection sort in this case?

(a) O(n)

(b) O(n2)

(c) O(n log n)

(d) O(n2)

 

4. What is the asymptotic running time of merge sort in this case?

(a) O(n)

(b) O(n2)

(c) O(n log n)

(d) O(n2)

 

5. What is the asymptotic running time of quick sort in this case?

 (a) O(n)

(b) O(n2)

(c) O(n log n)

(d) O(n2)

 

6. Linear search is highly inefficient compared to binary search when dealing with,

(a) Small, unsorted arrays.

(b) Small, sorted arrays.

(c) Large, unsorted arrays.

(d) Large, sorted arrays.

 

7. How many elements can be stored in the array a[3][5]?

(a) 15

(b) 13

(c) 10

(d) 8

 

8. Which of the following is the number of operations required by an algorithm to complete a task on n data elements in linear runtime?

(a) n3 + 9

(b) 3n2 + 3 n + 2

(c) 2n + 1

(d) 6

 

9. What is the running time of the following pseudo code?

public static int f3(int N) {

if (N == 0) return 1;

int x = 0;

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

x += f3(N-1);

return x;

}

(a) N2

(b) 2N

(c) N!

(d) log N

 

10. At most, how many comparisons are required to search a sorted vector of 1023 elements using the binary search algorithm?

(a) 10

(b) 15

(c) 20

(d) 30

 

Answer:

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


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

Interview questions and answers in data structure and algorithms

DSA quiz questions with answers explained

Solved true or false questions in DSA

Practice questions in data structures

Entrance exam questions with answers in Data structures for Tamilnadu engineering entrance

Entrance exam questions with answers in Data structures for IIT-JEE entrance exam

Entrance exam questions with answers in Data structures for JNTU engineering entrance

No comments:

Post a comment

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...

All time most popular contents