AP® Computer Science A Data Collections Multiple Choice Questions
Work through AP Computer Science A multiple-choice questions on Data Collections, then check each answer against a worked solution.
Free · no sign-up Open questions need no account. Sign up or log in to open the rest.
Subtopic: Sorting And Searching Clear filter
Multiple choice
Sorting And Searching
Question 132
Multiple choice
Sorting And Searching
Consider using insertion sort (processing index
i from 1 upward, inserting arr[i] into the sorted prefix arr[0..i-1]) on the array {8, 2, 6, 1, 4}.
What is the array after the first three iterations (i = 1, 2, 3) of the outer loop?
Pick an answer, then check it. The solution opens in a window.
BCorrect answer
Main Solution
Answer
Answer: B. Insertion sort builds a sorted prefix one element at a time. Starting from{8, 2, 6, 1, 4}:i = 1: insert
2 into {8} → {2, 8, 6, 1, 4}.i = 2: insert
6 into {2, 8} → {2, 6, 8, 1, 4}.i = 3: insert
1 into {2, 6, 8} → {1, 2, 6, 8, 4}.Option A stops after two iterations; option C is the final fully sorted result after all iterations.
Answer: Correct: B
A
{2, 6, 8, 1, 4}
B
{1, 2, 6, 8, 4}
C
{1, 2, 4, 6, 8}
D
{2, 1, 6, 8, 4}
Answer images
Question 133
Multiple choice
Sorting And Searching
Question 134
Multiple choice
Sorting and Searching
Question 135
Multiple choice
Sorting and Searching
Question 136
Multiple choice
Sorting and Searching
Question 137
Multiple choice
Sorting And Searching
Question 138
Multiple choice
Sorting And Searching
Question 131 of 139
Page 14 of 14
AP® and Advanced Placement® are registered trademarks of the College Board, which is not affiliated with, and does not endorse, Verityprep. Names are used for identification purposes only.

