Sorting and Searching with Arrays: viva questions and MCQs
Computer Programming Lab (C), Unit 7. 100+ Sorting and Searching with Arrays questions with explanations (Computer Programming Lab (C)). Topics: C Sorting, C Sorting Output. Take a free test now.
Topics
- C Sorting: searching, sorting, algorithm, bubble sort, binary search, quick sort, largest, sorted
- C Sorting Output: search, bubble sort, comparisons, element checked, middle element, sort ascending, early exit, elements makes
Key terms: searching, sorting, algorithm, bubble sort, binary search, quick sort, search, comparisons, element checked, middle element, sort ascending
Sample questions with answers
In sorting and searching, "Bubble sort" means:
Options: A) Uses only a constant amount of extra memory B) Repeatedly swaps adjacent elements that are out of order, O(n²) C) O(n) when the array is already sorted D) Repeatedly halves a sorted array to find the key, O(log n)
Answer: B) Repeatedly swaps adjacent elements that are out of order, O(n²). Bubble sort: Repeatedly swaps adjacent elements that are out of order, O(n²).
Linear search for 9 in {7, 3, 9, 1, 5} (index from 0) finds it at index:
Options: A) Not found (−1) B) 2 C) 3 D) 4
Answer: B) 2. Index counts from 0; −1 if absent.
In sorting and searching, "Quick sort" means:
Options: A) Partitions around a pivot and sorts the parts, O(n log n) average B) O(n) when the array is already sorted C) Uses only a constant amount of extra memory D) One complete traversal of the array in a sorting algorithm
Answer: A) Partitions around a pivot and sorts the parts, O(n log n) average. Quick sort: Partitions around a pivot and sorts the parts, O(n log n) average.