1.Which of the following sorting algorithms has the worst time complexity in the average case?

a) Merge Sort

b) Bubble Sort

c) Quick Sort

d) Insertion Sort

Answer: b) Bubble Sort

Explanation: Bubble Sort has a time complexity of O(n^2) in the average case, making it less efficient compared to other sorting algorithms.

2.In which sorting algorithm does the partitioning of elements occur?

a) Merge Sort

b) Quick Sort

c) Selection Sort

d) Heap Sort

Answer: b) Quick Sort

Explanation: Quick Sort partitions elements based on a pivot element and recursively sorts the partitions.

3.Which sorting algorithm is known for its stability, making it useful for sorting objects with multiple keys?

a) Merge Sort

b) Bubble Sort

c) Selection Sort

d) Insertion Sort

Answer: a) Merge Sort

Explanation: Merge Sort is stable as it maintains the relative order of equal elements.

4.The sorting algorithm which is not an in-place sorting algorithm is:

a) Merge Sort

b) Insertion Sort

c) Heap Sort

d) Quick Sort

Answer: a) Merge Sort

Explanation: Merge Sort requires additional space proportional to the size of the input array for merging subarrays.

5.Which sorting algorithm works by repeatedly selecting the minimum element from the unsorted portion and placing it at the beginning of the array?

a) Insertion Sort

b) Selection Sort

c) Quick Sort

d) Radix Sort

Answer: b) Selection Sort

Explanation: Selection Sort sorts by repeatedly selecting the minimum element from the unsorted portion and placing it at the beginning.

6.The worst-case time complexity of Quick Sort is:

a) O(n^2)

b) O(n log n)

c) O(log n)

d) O(n)

Answer: a) O(n^2)

Explanation: Quick Sort has a worst-case time complexity of O(n^2) when the pivot selection is poor.

7.Which searching algorithm requires the list to be sorted beforehand?

a) Sequential Search

b) Binary Search

c) Hashing

d) Indexing

Answer: b) Binary Search

Explanation: Binary Search operates on sorted lists and efficiently locates a target by repeatedly dividing the search interval in half.

8.What is the time complexity of Binary Search?

a) O(n)

b) O(log n)

c) O(n^2)

d) O(1)

Answer: b) O(log n)

Explanation: Binary Search has a time complexity of O(log n) as it halves the search space in each iteration.

9.Which search technique compares each element of the list with the target element until a match is found?

a) Sequential Search

b) Binary Search

c) Hashing

d) Indexing

Answer: a) Sequential Search

Explanation: Sequential Search scans through each element sequentially until it finds the target or reaches the end of the list.

10.Which data structure is primarily used for efficient retrieval of data based on keys?

a) Stack

b) Queue

c) Hash Table

d) Tree

Answer: c) Hash Table

Explanation: Hash Tables allow for constant-time average case retrieval of data based on keys.

11.Which sorting algorithm typically has the highest worst-case time complexity?

a) Merge Sort

b) Quick Sort

c) Heap Sort

d) Bubble Sort

Answer: c) Heap Sort

Explanation: Heap Sort has a worst-case time complexity of O(n log n), similar to Merge Sort and Quick Sort, but its constants make it slower in practice.

12.In which sorting algorithm does the concept of “swapping” play a crucial role in sorting elements?

a) Merge Sort

b) Quick Sort

c) Selection Sort

d) Radix Sort

Answer: c) Selection Sort

Explanation: Selection Sort involves swapping elements to place the minimum (or maximum) element in its correct position.

13.Which sorting algorithm is known for its adaptability to nearly sorted arrays?

a) Merge Sort

b) Quick Sort

c) Insertion Sort

d) Radix Sort

Answer: c) Insertion Sort

Explanation: Insertion Sort performs efficiently on nearly sorted arrays due to its linear time complexity for such cases.

14.What is the primary objective of hashing?

a) Sorting elements

b) Searching elements

c) Storing elements

d) Distributing elements uniformly

Answer: b) Searching elements

Explanation: Hashing enables efficient searching by quickly locating elements based on their keys.

15.Which sorting algorithm does not follow the divide-and-conquer strategy?

a) Merge Sort

b) Quick Sort

c) Heap Sort

d) Insertion Sort

Answer: d) Insertion Sort

Explanation: Insertion Sort builds the final sorted array one element at a time by repeatedly inserting the next element into its correct position.

16.Which sorting algorithm is not suitable for large datasets due to its quadratic time complexity?

a) Merge Sort

b) Quick Sort

c) Bubble Sort

d) Radix Sort

Answer: c) Bubble Sort

Explanation: Bubble Sort’s time complexity of O(n^2) makes it inefficient for sorting large datasets.

17.Which searching technique has a time complexity of O(1) in the average case?

a) Sequential Search

b) Binary Search

c) Hashing

d) Indexing

Answer: c) Hashing

Explanation: Hashing allows for constant-time average case retrieval of data.

18.Which sorting algorithm is inherently stable?

a) Quick Sort

b) Heap Sort

c) Merge Sort

d) Shell Sort

Answer: c) Merge Sort

Explanation: Merge Sort maintains the relative order of equal elements, making it stable.

19.In which sorting algorithm does the term “partitioning” refer to dividing the array into two partitions based on a pivot element?

a) Merge Sort

b) Quick Sort

c) Heap Sort

d) Insertion Sort

Answer: b) Quick Sort

Explanation: Quick Sort partitions the array based on a chosen pivot element.

20.Which data structure is commonly used to implement priority queues efficiently?

a) Stack

b) Queue

c) Hash Table

d) Heap

Answer: d) Heap

Explanation: Heaps are commonly used to implement priority queues due to their efficient insertion and removal of the highest (or lowest) priority element.