167
87.6k
Chapter:

50+ Searching, Sorting and Hashing Techniques Solved MCQs

in Data Structures (DS)

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Bachelor of Science in Computer Science FY (BSc CS) , Bachelor of Science in Information Technology FY (BSc IT) , Bachelor of Computer Applications (BCA) .

Chapters

Chapter: Searching, Sorting and Hashing Techniques
1.

What is the best case for linear search?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(1)
Answer» D. O(1)
2.

What is the worst case for linear search?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(1)
Answer» C. O(n)
3.

What is the best case and worst case complexity of ordered linear search?

A. O(nlogn), O(logn)
B. O(logn), O(nlogn)
C. O(n), O(1)
D. O(1), O(n)
Answer» D. O(1), O(n)
4.

Which of the following is a disadvantage of linear search?

A. Requires more space
B. Greater time complexities compared to other searching algorithms
C. Not easy to understand
D. Not easy to implement
Answer» B. Greater time complexities compared to other searching algorithms
5.

What is the advantage of recursive approach than an iterative approach?

A. Consumes less memory
B. Less code and easy to implement
C. Consumes more memory
D. More code has to be written
Answer» B. Less code and easy to implement
6.

Given an input arr = {2,5,7,99,899}; key = 899; What is the level of recursion?

A. 5
B. 2
C. 3
D. 4
Answer» C. 3
7.

Given an array arr = {45,77,89,90,94,99,100} and key = 99; what are the mid values(corresponding array elements) in the first and second levels of recursion?

A. 90 and 99
B. 90 and 94
C. 89 and 99
D. 89 and 94
Answer» A. 90 and 99
8.

What is the worst case complexity of binary search using recursion?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» B. O(logn)
9.

What is the average case time complexity of binary search using recursion?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» B. O(logn)
10.

Which of the following is not an application of binary search?

A. To find the lower/upper bound in an ordered sequence
B. Union of intervals
C. Debugging
D. To search in unordered list
Answer» D. To search in unordered list
11.

Binary Search can be categorized into which of the following?

A. Brute Force technique
B. Divide and conquer
C. Greedy algorithm
D. Dynamic programming
Answer» B. Divide and conquer
12.

Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are done until the element is found?

A. 1
B. 3
C. 4
D. 2
Answer» D. 2
13.

Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid values(corresponding array elements) generated in the first and second iterations?

A. 90 and 99
B. 90 and 100
C. 89 and 94
D. 94 and 99
Answer» A. 90 and 99
14.

What is the time complexity of binary search with iteration?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» B. O(logn)
15.

What is an external sorting algorithm?

A. Algorithm that uses tape or disk during the sort
B. Algorithm that uses main memory during the sort
C. Algorithm that involves swapping
D. Algorithm that are considered ‘in place’
Answer» A. Algorithm that uses tape or disk during the sort
16.

What is an internal sorting algorithm?

A. Algorithm that uses tape or disk during the sort
B. Algorithm that uses main memory during the sort
C. Algorithm that involves swapping
D. Algorithm that are considered ‘in place’
Answer» B. Algorithm that uses main memory during the sort
17.

What is the worst case complexity of bubble sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» D. O(n2)
18.

What is the average case complexity of bubble sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» D. O(n2)
19.

Which of the following is not an advantage of optimised bubble sort over other sorting techniques in case of sorted elements?

A. It is faster
B. Consumes less memory
C. Detects whether the input is already sorted
D. Consumes less time
Answer» C. Detects whether the input is already sorted
20.

The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array?

A. 4
B. 2
C. 1
D. 0
Answer» A. 4
21.

What is the best case efficiency of bubble sort in the improvised version?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» C. O(n)
22.

The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array with improvised version?

A. 4
B. 2
C. 1
D. 0
Answer» B. 2
23.

What is an in-place sorting algorithm?

A. It needs O(1) or O(logn) memory to create auxiliary locations
B. The input is already sorted and in-place
C. It requires additional storage
D. It requires additional space
Answer» A. It needs O(1) or O(logn) memory to create auxiliary locations
24.

In the following scenarios, when will you use selection sort?

A. The input is already sorted
B. A large file has to be sorted
C. Large values need to be sorted with small keys
D. Small values need to be sorted with large keys
Answer» C. Large values need to be sorted with small keys
25.

What is the worst case complexity of selection sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» D. O(n2)
26.

What is the advantage of selection sort over other sorting techniques?

A. It requires no additional storage space
B. It is scalable
C. It works best for inputs which are already sorted
D. It is faster than any other sorting technique
Answer» A. It requires no additional storage space
27.

What is the average case complexity of selection sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» D. O(n2)
28.

What is the disadvantage of selection sort?

A. It requires auxiliary memory
B. It is not scalable
C. It can be used for small keys8
D. It takes linear time to sort the elements
Answer» B. It is not scalable
29.

The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort respectively are,

A. 5 and 4
B. 4 and 5
C. 2 and 4
D. 2 and 5
Answer» A. 5 and 4
30.

The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number of iterations in selection sort and bubble sort respectively are,

A. 5 and 4
B. 1 and 4
C. 0 and 4
D. 4 and 1
Answer» D. 4 and 1
31.

What is the best case complexity of selection sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2)
Answer» D. O(n2)
32.

Shell sort is also known as

A. diminishing decrement sort
B. diminishing increment sort
C. partition exchange sort
D. diminishing insertion sort
Answer» B. diminishing increment sort
33.

Statement 1: Shell sort is a stable sorting algorithm. Statement 2: Shell sort is an in-place sorting algorithm.

A. Both statements are true
B. Statement 2 is true but statement 1 is false
C. Statement 2 is false but statement 1 is true
D. none
Answer» B. Statement 2 is true but statement 1 is false
34.

Shell sort is applied on the elements 27 59 49 37 15 90 81 39 and the chosen decreasing sequence of increments is (5,3,1). The result after the first iteration will be

A. 27 59 49 37 15 90 81 39
B. 27 59 37 49 15 90 81 39
C. 27 59 39 37 15 90 81 49
D. 15 59 49 37 27 90 81 39
Answer» C. 27 59 39 37 15 90 81 49
35.

Shell sort is an improvement on

A. insertion sort
B. selection sort
C. binary tree sort
D. quick sort
Answer» A. insertion sort
36.

An array that is first 7-sorted, then 5-sorted becomes

A. 7-ordered
B. 5-ordered
C. both 2-ordered and 5-ordered
D. both 7-ordered and 5-ordered
Answer» D. both 7-ordered and 5-ordered
37.

If Hibbard increments (h1= 1, h2= 3, h3= 7, …, hk = 2k–1) are used in a Shell sortimplementation, then the best case time complexity will be

A. O(nlogn)
B. O(n)
C. O(n2)
D. O(logn)
Answer» A. O(nlogn)
38.

Records R1, R2, R3,.. RN with keys K1, K2, K3,.. KN are said to be h-ordered, if

A. Ki <= Ki+h for 1<= i*h <= N
B. Kh <= Ki+h for 1<= i <= N
C. Ki <= Kh for 1<= i <= h
D. Ki <= Ki+h for 1<= i <= N-h
Answer» D. Ki <= Ki+h for 1<= i <= N-h
39.

Which of the following is true?

A. Shell sort’s passes completely sort the elements before going on to the next-smallest gap while Comb sort’s passes do not completely sort the elements
B. Shell sort’s passes do not completely sort the elements before going on to the next-smallest gap like in Comb sort
C. Comb sort’s passes completely sort the elements before going on to the next-smallest gap like in Shell sort
D. Shell sort’s passes do not completely sort the elements before going on to the next-smallest gap while Comb sort’s passes completely sort the elements
Answer» A. Shell sort’s passes completely sort the elements before going on to the next-smallest gap while Comb sort’s passes do not completely sort the elements
40.

Which of the following is the distribution sort?

A. Heap sort
B. Smooth sort
C. Quick sort
D. LSD radix sort
Answer» D. LSD radix sort
41.

What is the worst case time complexity of LSD radix sort?

A. O(nlogn)
B. O(wn)
C. O(n)
D. O(n + w)
Answer» B. O(wn)
42.

LSD radix sort requires passes to sort N elements.

A. (w/logR)
B. N(w/logR)
C. (w/log(RN))
D. (wN/log(N))
Answer» A. (w/logR)
43.

Which of the following is false?

A. LSD radix sort is an integer sorting algorithm
B. LSD radix sort is a comparison sorting algorithm
C. LSD radix sort is a distribution sort
D. LSD radix sort uses bucket sort
Answer» B. LSD radix sort is a comparison sorting algorithm
44.

Which of the following sorting algorithm is stable?

A. Heap sort
B. Selection sort
C. In-place MSD radix sort
D. LSD radix sort
Answer» D. LSD radix sort
45.

Which of the following should be used to sort a huge database on a fixed-length key field?

A. Insertion sort
B. Merge sort
C. LSD radix sort
D. Quick sort
Answer» C. LSD radix sort
46.

Which of the following is a combination of LSD and MSD radix sorts?

A. Forward radix sort
B. 3-way radix quick sort
C. Trie base radix sort
D. Flash sort
Answer» A. Forward radix sort
47.

Which of the following is true for the LSD radix sort?

A. works best for variable length strings
B. accesses memory randomly
C. inner loop has less instructions
D. sorts the keys in left-to-right order
Answer» B. accesses memory randomly
48.

Which scheme uses a randomization approach?

A. hashing by division
B. hashing by multiplication
C. universal hashing
D. open addressing
Answer» C. universal hashing
49.

Which hash function satisfies the condition of simple uniform hashing?

A. h(k) = lowerbound(km)
B. h(k)= upperbound(mk)
C. h(k)= lowerbound(k)
D. h(k)= upperbound(k)
Answer» A. h(k) = lowerbound(km)
50.

What is the hash function used in the division method?

A. h(k) = k/m
B. h(k) = k mod m
C. h(k) = m/k
D. h(k) = m mod k
Answer» B. h(k) = k mod m

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.