FBISE, NCP & NBF-aligned resources for Classes 9–12
Browse by Class
Browse by Type
Computer Chapter 2 : Topic 2.4
Applying Linear Search, Binary Search, Insertion Sort and Bubble Sort
1 / 21
A linear search is applied to the list $\mathbf{\lbrack 18,\ 7,\ 25,\ 11,\ 32,\ 9\rbrack}$ to find $\mathbf{11}$. Using 1-based positions, where is the value found?
Reasoning: Linear search checks the elements sequentially. The value $\mathbf{11}$ occurs at the fourth position.
2 / 21
Binary search is applied to the sorted list $\mathbf{\lbrack 4,\ 9,\ 13,\ 18,\ 24,\ 31,\ 3}\mathbf{7\rbrack}$ to find $\mathbf{31}$. Which value is examined first?
Reasoning: The middle element of the seven-element list is the fourth value,$\mathbf{18}$.
3 / 21
Binary search is used to find $\mathbf{42}$ in the sorted list $\mathbf{\lbrack}\mathbf{6,\ 12,\ 19,\ 27,\ 35,\ 42,\ 51\rbrack}$. Which sequence of values is examined?
Reasoning: The middle value is $\mathbf{27}$. Since $\mathbf{42\ } > \ \mathbf{27}$, the right half is searched, where the next middle value is $\mathbf{42}$.
4 / 21
Binary search is performed on $\mathbf{\lbrack 3,\ 8,\ 14,\ 21,\ 29,\ 36,\ 44,\ 52\rbrack}$ to find $\mathbf{10}$. Which values may be compared before the search ends unsuccessfully?
Reasoning: Binary search first checks $\mathbf{21}$, then searches the lower half and checks $\mathbf{8}$, followed by $\mathbf{14}$. No value $\mathbf{10}$ remains in the search range.
5 / 21
A programmer must immediately search for $\mathbf{17}$ in the unsorted list $\mathbf{\lbrack 23,\ 5,\ 17,\ 9,\ 31,\ 12\rbrack}$. Which algorithm can be applied without first rearranging the list?
Reasoning: Linear search works directly on both sorted and unsorted lists, while binary search requires sorted data.
6 / 21
The list $\mathbf{\lbrack 28,\ 11,\ 35,\ 7,\ 19,\ 42,\ 15\rbrack}$ will be searched hundreds of times for different values. Which approach is generally more suitable?
Reasoning: Sorting once allows repeated searches to be performed efficiently using binary search.
7 / 21
Bubble sort arranges $\mathbf{\lbrack 7,\ 3,\ 9,\ 2,\ 6\rbrack}$ in ascending order. What is the list after the first complete pass?
Reasoning: Adjacent comparisons move the largest value, $\mathbf{9}$, to the final position during the first pass.
8 / 21
During the first pass of bubble sort on $\mathbf{\lbrack 12,\ 5,\ 8,\ 3,\ 10\rbrack}$, how many adjacent comparisons are performed?
Reasoning: A list of five elements requires four adjacent comparisons during its first complete pass.
9 / 21
Bubble sort is applied to $\mathbf{\lbrack 5,\ 1,\ 4,\ 2,\ 8\rbrack}$. What is the list after the second complete pass?
Reasoning: After the first pass, the list is $\mathbf{\lbrack 1,\ 4,\ 2,\ 5,\ 8\rbrack}$. The second pass changes it to $\mathbf{\lbrack 1,\ 2,\ 4,\ 5,\ 8\rbrack}$.
10 / 21
An optimized bubble sort processes the list $\mathbf{\lbrack 2,\ 5,\ 9,\ 13,\ 18\rbrack}$. What should happen after its first pass?
Reasoning: No swaps occur because the list is already sorted. An optimized bubble sort detects this and terminates early.
11 / 21
Insertion sort is applied to $\mathbf{\lbrack 9,\ 4,\ 7,\ 2,\ 6\rbrack}$. What is the list after the first three elements have been processed?
Reasoning: First, $\mathbf{4}$ is inserted before $\mathbf{9}$. Then $\mathbf{7}$ is inserted between $\mathbf{4}$ and $\mathbf{9}$.
12 / 21
Insertion sort processes $\mathbf{\lbrack 8,\ 3,\ 6,\ 1,\ 5\rbrack}$ in ascending order. What is the list immediately after inserting 1 into the sorted portion?
Reasoning: Before processing $\mathbf{1}$, the sorted portion is $\mathbf{\lbrack 3,\ 6,\ 8\rbrack}$. All three values shift right so that 1 can be placed at the beginning.
13 / 21
While insertion sorting $\mathbf{\lbrack 2,\ 5,\ 7,\ 9,\ 4\rbrack}$, how many existing values shift to the right when $\mathbf{4}$ is inserted?
Reasoning: The values $\mathbf{5}$, $\mathbf{7}$, and $\mathbf{9}$ are greater than $\mathbf{4}$, so all three shift one position to the right.
14 / 21
Selection sort is applied to $\mathbf{\lbrack 29,\ 10,\ 14,\ 37,\ 13\rbrack}$. What is the list after the first pass?
Reasoning: Selection sort identifies $\mathbf{10}$ as the smallest value and swaps it with the first value, $\mathbf{29}$.
15 / 21
Selection sort is used on $\mathbf{\lbrack 20,\ 12,\ 10,\ 15,\ 2\rbrack}$. What is the list after two complete passes?
Reasoning: The first pass swaps $\mathbf{2}$ with $\mathbf{20}$, producing $\mathbf{\lbrack 2,\ 12,\ 10,\ 15,\ 20\rbrack}$. The second pass swaps $\mathbf{10}$ with $\mathbf{12}$.
16 / 21
The records $\mathbf{\lbrack 7A,\ 3B,\ 7C,\ 2D\rbrack}$ are sorted by their numeric values using a stable sorting algorithm. Which result correctly preserves the original order of equal values?
Reasoning: A stable sort keeps $\mathbf{7A}$ before $\mathbf{7C}$ because they appeared in that order in the original list.
17 / 21
Bubble sort is modified to arrange $\mathbf{\lbrack 4,\ 9,\ 2,\ 7,\ 5\rbrack}$ in descending order. What is the list after the first complete pass?
Reasoning: In descending bubble sort, smaller adjacent values move toward the end. After one pass, the smallest value, $\mathbf{2}$, reaches the last position.
18 / 21
Insertion sort arranges $\mathbf{\lbrack 6,\ 10,\ 4,\ 8,\ 2\rbrack}$ in descending order. What is the list after processing the first three elements?
Reasoning: The first two values become $\mathbf{\lbrack 10,\ 6\rbrack}$. The value $\mathbf{4}$ is then placed after both because the order is descending.
19 / 21
Binary search is used to find $\mathbf{16}$ in $\mathbf{\lbrack 2,\ 5,\ 9,\ 12,\ 16,\ 20,\ 27,\ 31,\ 38\rbrack}$. After first comparing with $\mathbf{16}$, what happens?
Reasoning: The middle element of the nine-element list is $\mathbf{16}$, so the target is found in the first comparison.
20 / 21
Consider the nearly sorted list $\mathbf{\lbrack 2,\ 4,\ 6,\ 8,\ 10,\ 9,\ 12\rbrack}$. Which sorting algorithm is likely to perform efficiently?
Reasoning: Insertion sort performs efficiently on nearly sorted data because it only needs to reposition the misplaced value.
21 / 21
An algorithm transforms the list as follows: $\mathbf{\lbrack 8,\ 3,\ 6,\ 2\rbrack}$ $\mathbf{\lbrack 3,\ 8,\ 6,\ 2\rbrack}$ $\mathbf{\lbrack 3,\ 6,\ 8,\ 2\rbrack}$ $\mathbf{\lbrack 2,\ 3,\ 6,\ 8\rbrack}$ Which sorting algorithm is being demonstrated?
Reasoning: The algorithm takes each new element and inserts it into the correct position within the already sorted portion of the list.
Your score is
Restart quiz