1/8
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
An algorithm that sorts an array swaps _____.
two elements at a time
Which is sorted into ascending order?
Sally, Sam, Sandy, Samantha, Sal
Ral, Reece, Rita, Ryan
Don, Dan, Dale, Dana
Alan, Andy, Al, Adam
Ral, Reece, Rita, Ryan
Which of the following is not an example of sorting?
Arranging patient records alphabetically
Arranging employee details based on beginning dates
Arranging student records neatly on a desk
Arranging musical instruments based on the number of strings they have
Arranging student records neatly on a desk
In selection sort, the smallest element is selected and swapped with the _____ unsorted element.
leftmost
The array [67, 23, 32, 80, 53, 60] is to be sorted using selection sort. What is the order of the elements after the third swap?
23, 32, 53, 80, 67, 60
What statement must replace the XXX to complete the selection sort algorithm below?
void selectionSort(int[] numbers) { for (int i = 0; i < numbers.length - 1; i++) { int indexSmallest = i; for (int j = i + 1; j < numbers.length; j++) { if (numbers[j] < numbers[indexSmallest]) { indexSmallest = j; } } int temp = numbers[i]; XXX numbers[indexSmallest] = temp; } }
numbers[i] = numbers[indexSmallest];
Given the array [77, 75, 70, 50, 10], what is the order of the elements after completing insertion sort's second outer loop iteration?
70, 75, 77, 50, 10
What replaces XXX to complete the insertion sort algorithm?
for (int i = 1; i < numbers.length; i++) { int j = i; XXX { int temp = numbers[j]; numbers[j] = numbers[j - 1]; numbers[j - 1] = temp; j--; } }
while (j > 0 && numbers[j] < numbers[j - 1])
What is the SMALLEST number of swaps that insertion sort may perform when sorting 20 elements?
0