
Sorting Questions
Authored by SAMUEL KEENER
Computers
11th Grade
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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}
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Python with DataScience
Quiz
•
7th Grade - University
10 questions
Podstawy Pythona
Quiz
•
9th - 12th Grade
10 questions
DL Refresher
Quiz
•
KG - Professional Dev...
10 questions
Asesmen Sumatif
Quiz
•
11th Grade
10 questions
IT Quiz
Quiz
•
11th - 12th Grade
14 questions
ITGS - IT Systems (Hardware)
Quiz
•
10th - 12th Grade
10 questions
TỪ BÀI TOÁN ĐẾN CHƯƠNG TRÌNH
Quiz
•
11th Grade
13 questions
ICT and Retail Industry
Quiz
•
8th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade