
Searching ad Sorting

Passage
•
Computers
•
9th - 12th Grade
•
Medium

Arasaka Teacher
Used 3+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following best describes the linear search algorithm for an array?
It checks each element in the sequence until the target is found or the end is reached
It repeatedly divides the sequence in half to locate the target value
It sorts the array first then searches for the target using binary search
It jumps to the middle of the sequence then searches toward one end ond
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
int[] values = {10, 20, 30};
int target = 25;
int index = -1;
for (int i = 0; i < values.length; i++) {
if (values[i] == target) {
index = i;
}
}
System.out.println(index);
What is the output of the code above?
ArrayOutOfBoundsException
-1
3
endless loop
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
int[] arr = {5, 8, 2, 8, 7};
int target = 8;
int index = -1;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == target) {
index = i;
break;
}
}
System.out.println(index);
}
What is the output of the code above?
-1
1
3
8
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
int[] arr = {5, 8, 2, 8, 7};
int target = 8;
int count = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == target) {
count++;
}
}
System.out.println(count);
}
What is the output of the code above?
0
1
2
5
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following must be true in order to use binary search on an array?
The array's elements must be sorted
The array can't have 2 of the same value
The array must be divisible by 2
The array can be in any order to start
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
If you have a very large array of values (100,000+), which search method is most efficient?
linear search
binary search
both linear search and binary search
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the code?
-1
2
6
3
Create a free account and access millions of resources
Similar Resources on Wayground
17 questions
AP CS ArrayLists

Quiz
•
12th Grade
15 questions
AP Computer Science A Quiz

Quiz
•
12th Grade
15 questions
Computer Science Review

Quiz
•
10th - 12th Grade
16 questions
STM30243 - TOPIC 4

Quiz
•
9th Grade
15 questions
Unit 8 - Searching and Sorting

Quiz
•
9th - 12th Grade
10 questions
C Programming - Dia Aberto - EPC

Quiz
•
9th - 12th Grade
10 questions
Advanced Java Study Guide

Quiz
•
11th - 12th Grade
10 questions
Array

Quiz
•
10th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
20 questions
Analog vs Digital

Quiz
•
9th - 12th Grade
10 questions
CTEA Computer Vocab Terms #1

Quiz
•
12th Grade
10 questions
Exploring Cybersecurity Techniques and Threats

Interactive video
•
6th - 10th Grade
10 questions
Understanding the Internet and Data Transmission

Interactive video
•
7th - 12th Grade