AP Computer Science A Quiz
19 questions · no time limit
0:00
SELECTION AND ITERATION
Question 1 of 19
No time limit
Current
Answered
Flagged
Not seen
A simple selection sort is used to sort n product prices, regardless of current ordering.
public static void selectionSort(int[] prices) {
for (int i = 0; i < prices.length - 1; i++) {
int minIndex = i;
for (int j = i + 1; j < prices.length; j++) {
if (prices[j] < prices[minIndex]) {
minIndex = j;
}
}
int temp = prices[i];
prices[i] = prices[minIndex];
prices[minIndex] = temp;
}
}What is the run-time complexity of the algorithm in the code snippet? YOUR PROGRESS
19
QUESTIONS
Ready when you are
Answer in any order. Your progress shows here as you go.
QUESTIONS
KEYBOARD
Pick an answer ABCD
Next question ↵→
Previous ←
Flag for review F
Answers save as you go · flagged questions come back at the end