Chapter-5 Sorting — Online MCQ Test
COMPUTER SCIENCE · Grade 12 · CBSE(NCERT)
Practice Chapter-5 Sorting with a free chapter-wise online MCQ test.
This chapter covers: bubble sort - insertion sort.
AI-generated questions from basic to board-exam level, with instant results and explanations.
Chapter-5 Sorting — Important Questions & Answers
What is the primary characteristic of Linear Search?
- A. It searches elements sequentially from the beginning
- B. It requires the array to be sorted
- C. It divides the array into halves
- D. It uses divide and conquer strategy
Answer: A. It searches elements sequentially from the beginning
Linear search checks each element one by one from the start until the target is found, regardless of whether the array is sorted or not.
Linear search checks each element one by one from the start until the target is found, regardless of whether the array is sorted or not.
Which search algorithm requires the array to be sorted?
- A. Linear Search
- B. Binary Search
- C. Jump Search
- D. Both B and C
Answer: D. Both B and C
Binary Search and Jump Search both require a pre-sorted array to work correctly, as they rely on the sorted order to eliminate portions of the search space.
Binary Search and Jump Search both require a pre-sorted array to work correctly, as they rely on the sorted order to eliminate portions of the search space.
What is the time complexity of Linear Search in the worst case?
- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n²)
Answer: C. O(n)
In the worst case, Linear Search may have to check all n elements in the array when the target element is at the end or not present.
In the worst case, Linear Search may have to check all n elements in the array when the target element is at the end or not present.
What is the time complexity of Binary Search in the best case?
- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n log n)
Answer: A. O(1)
In the best case, if the middle element is the target element itself, Binary Search finds it in just one comparison, resulting in O(1) time complexity.
In the best case, if the middle element is the target element itself, Binary Search finds it in just one comparison, resulting in O(1) time complexity.
Which sorting algorithm has the same best, average, and worst-case time complexity?
- A. Bubble Sort
- B. Insertion Sort
- C. Selection Sort
- D. Quick Sort
Answer: C. Selection Sort
Selection Sort always has O(n²) complexity regardless of input order because it always performs n(n-1)/2 comparisons to find the minimum element in each pass.
Selection Sort always has O(n²) complexity regardless of input order because it always performs n(n-1)/2 comparisons to find the minimum element in each pass.
Consider searching for an element in a sorted array of 1000 elements. How many comparisons would Binary Search require at most?
- A. 10
- B. 100
- C. 500
- D. 1000
Answer: A. 10
Binary Search requires at most log₂(1000) ≈ 10 comparisons because it eliminates half of the remaining elements with each comparison.
Binary Search requires at most log₂(1000) ≈ 10 comparisons because it eliminates half of the remaining elements with each comparison.
Compare Linear Search and Binary Search: when is Linear Search preferable to Binary Search?
- A. Linear Search is always preferable
- B. When the array is small and unsorted
- C. When the array is large and sorted
- D. They always have the same efficiency
Answer: B. When the array is small and unsorted
For small unsorted arrays, the overhead of sorting for Binary Search makes Linear Search more practical despite its O(n) complexity.
For small unsorted arrays, the overhead of sorting for Binary Search makes Linear Search more practical despite its O(n) complexity.
Consider an array being sorted using Insertion Sort. After 3 passes, 3 elements are in their final sorted positions. What can be concluded?
- A. The entire array is sorted
- B. The first 3 elements are in correct positions
- C. Exactly 3 more passes are needed
- D. The array has at least 6 elements
Answer: B. The first 3 elements are in correct positions
In Insertion Sort, after k passes, the first k+1 elements are guaranteed to be in their final correct sorted positions.
In Insertion Sort, after k passes, the first k+1 elements are guaranteed to be in their final correct sorted positions.
In a highly competitive exam scenario, searching 10^7 records for a specific ID where records are sorted by ID, which algorithm combination would be optimal and why?
- A. Linear Search because it's simpler
- B. Bubble Sort followed by Linear Search for accuracy
- C. Binary Search directly on the sorted records to minimize comparisons
- D. Insertion Sort to maintain sorted order during search
Answer: C. Binary Search directly on the sorted records to minimize comparisons
Binary Search on 10^7 sorted records requires only ~23 comparisons worst case, far superior to Linear Search's 10^7 comparisons, making it optimal for this competitive scenario.
Binary Search on 10^7 sorted records requires only ~23 comparisons worst case, far superior to Linear Search's 10^7 comparisons, making it optimal for this competitive scenario.
A programmer implements a sorting algorithm that compares each element with all previous elements and inserts it in the correct position. The algorithm uses O(1) extra space and is stable. Which algorithm did they implement?
- A. Bubble Sort
- B. Selection Sort
- C. Insertion Sort
- D. Quick Sort
Answer: C. Insertion Sort
The description matches Insertion Sort perfectly: it compares with previous elements, maintains stability, uses O(1) space, and places elements in correct positions.
The description matches Insertion Sort perfectly: it compares with previous elements, maintains stability, uses O(1) space, and places elements in correct positions.