Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

# Sorting MCQ

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