Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Practice Questions

Work through AP Computer Science A practice questions on Data Collections, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Subtopic: Sorting And Searching Clear filter

Questions 1–10 of 139
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10

Question 1

Multiple choice Sorting And Searching
Consider the following code segment from an insertion sort program. for (int j = 1; j < arr.length; j++) { int insertItem = arr[j]; int k = j - 1; while (k >= 0…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2

Multiple choice Sorting And Searching
Questions refer to the following information. Consider the following sort method. This method correctly sorts the elements of array data into increasing order.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3

Multiple choice Sorting And Searching
Consider the following sort method. This method correctly sorts the elements of array data into increasing order. public static void sort(int[] data) { for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 4

Multiple choice Sorting And Searching
Questions refer to the following information. Consider the following binarySearch method. The method correctly performs a binary search. /** Precondition: data…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 5

Multiple choice Sorting And Searching
Suppose the binarySearch method is called with an array containing 2,000 elements sorted in increasing…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 6

Multiple choice Sorting And Searching
The following incomplete method is intended to sort its array parameter arr in increasing order. // postcondition: arr is sorted in increasing order public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice Sorting And Searching
The following incomplete method is intended to sort the array a in ascending order. public void sort() { int maxCompare = a.length - 1; int lIndex = 0; int temp…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice Sorting And Searching
Which of the following correctly shows the iterations of an ascending (from…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 9

Multiple choice Sorting And Searching
What is printed when the following main method is executed? public class Searcher { private int[] arr = {1,3,5,8,9}; public int mystery(int low, int high, int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 10

Multiple choice Sorting And Searching
Which of the following correctly shows the iterations of an ascending (from…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1 of 139
Page 1 of 14