
Sorting Questions
Quiz
•
Computers
•
11th Grade
•
Hard
SAMUEL KEENER
Used 3+ times
FREE Resource
Enhance your content
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Assume that insertionSort has been called with an ArrayList parameter that has been initialized with the following Integer objects.
[5, 2, 4, 1, 3, 6]
What will the contents of data be after three passes of the outside loop (i.e., when j == 3 at the point indicated by /* End of outer loop */) ?
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 5, 4, 6]
[1, 2, 4, 5, 3, 6]
[2, 4, 5, 1, 3, 6]
[5, 2, 1, 3, 4, 6]
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Assume that array arr has been defined and initialized with the values {5, 4, 3, 2, 1}. What are the values in array arr after two passes of the for loop (i.e., when j = 2 at the point indicated by / end of for loop / ) ?
{2, 3, 4, 5, 1}
{3, 2, 1, 4, 5}
{3, 4, 5, 2, 1}
{3, 5, 2, 3, 1}
{5, 3, 4, 2, 1}
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
The following declaration and method call appear in a method in the same class as insertionSort.
int[] arr = {4, 12, 4, 7, 19, 6};
insertionSort(arr);
How many times is the statement possibleIndex--; in line 10 of the method executed as a result of the call to insertionSort ?
2
3
4
5
6
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
The following declaration and method call appear in the same class as selectionSort.
int[] vals = {5, 10, 2, 1, 12};
selectionSort(vals);
How many times is the statement minIndex = k; in line 11 of the method executed as a result of the call to selectionSort ?
0
1
2
3
4
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following changes should be made so that selectSort will work as intended?
Line 1 should be changed to
for (int j = 0; j < numbers.length - 2; j++)
Line 2 should be changed to
int pos = j;
Line 3 should be changed to
for (int k = 0; k < numbers.length; k++)
Line 4 should be changed to
if (numbers[k] > numbers[pos])
Line 5 should be changed to
k = pos;
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Assume arr is the following array.
{"Ann","Mike","Walt","Lisa","Shari","Jose","Mary",“Bill”}
What is the intermediate value of arr after two iterations of the outer for loop in the call sort(arr)?
"Ann""Mike""Walt""Lisa""Shari""Jose""Mary"“Bill”
"Ann""Mike""Lisa""Shari""Jose""Mary"“Bill”"Walt"
"Ann"“Bill”"Jose""Lisa""Mary""Mike""Shari""Walt"
"Ann""Mike"“Bill”"Lisa""Mary""Jose""Shari""Walt"
"Walt""Shari""Ann""Lisa""Mike""Jose""Mary"“Bill”
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Assume that sort is called with the array {6, 3, 2, 5, 4, 1}. What will the value of data be after three passes of the outer loop (i.e., when j = 2 at the point indicated by / End of outer loop /) ?
{1, 2, 3, 4, 5, 6}
{1, 2, 3, 5, 4, 6}
{1, 2, 3, 6, 5, 4}
{1, 3, 2, 4, 5, 6}
{1, 3, 2, 5, 4, 6}
8.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Assume that sort is called with the array {1, 2, 3, 4, 5, 6}. How many times will the expression indicated by /* Compare values / and the statement indicated by / Assign to temp */ execute?
Compare values: 15
Assign to temp: 0
Compare values: 15
Assign to temp: 5
Compare values: 15
Assign to temp: 6
Compare values: 21
Assign to temp: 5
Compare values: 21
Assign to temp: 6
9.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Assume that swap(arr, j, pos) exchanges the values of arr[j] and arr[pos]. Which of the following could be used to replace /* missing code */ so that executing the code segment sorts the values in array arr?
k = j - 1; k > 0; k--
k = j - 1; k >= 0; k--
k = 1; k < arr.length; k++
k = 1; k > arr.length; k++
k = 0; k <= arr.length; k++
Similar Resources on Wayground
10 questions
MATLAB 2
Quiz
•
KG - University
12 questions
Informatika 1
Quiz
•
8th - 12th Grade
5 questions
AP CSA Intro to ArrayList (7.1)
Quiz
•
10th - 12th Grade
10 questions
De 1 - Access
Quiz
•
9th - 12th Grade
10 questions
MICROSOFT EXCEL
Quiz
•
9th - 11th Grade
10 questions
Arrays
Quiz
•
11th Grade - University
10 questions
Quiz Javascript Basic Pertemuan 3
Quiz
•
9th - 12th Grade
12 questions
Text File Pop Quiz
Quiz
•
11th Grade
Popular Resources on Wayground
20 questions
Brand Labels
Quiz
•
5th - 12th Grade
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
20 questions
ELA Advisory Review
Quiz
•
7th Grade
15 questions
Subtracting Integers
Quiz
•
7th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
10 questions
Multiplication and Division Unknowns
Quiz
•
3rd Grade
10 questions
Exploring Digital Citizenship Essentials
Interactive video
•
6th - 10th Grade