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 11–20 of 139
  1. 11
  2. 12
  3. 13
  4. 14
  5. 15
  6. 16
  7. 17
  8. 18
  9. 19
  10. 20

Question 11

Multiple choice Sorting And Searching
Which of the following is (are) true? I. Insertion sort takes longer when the array is sorted in ascending order and you want it sorted in…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 12

Multiple choice Sorting And Searching
Which replacement for /* missing code */ sorts a in ascending order? public static void sort(int[] a) { int maxCompare = a.length - 1 int savedIndex = 0 int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 13

Multiple choice Sorting And Searching
Which correctly shows the successive outer-loop…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 14

Multiple choice Sorting And Searching
A recursive binary search on a sorted 10-element array uses mid=(low+high)/2 and returns −1 only…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 15

Multiple choice Sorting And Searching
How many calls to mystery occur, including the initial call, for mystery(0,4,5) with arr={1,2,3,5,7}? private int[] arr; public int mystery(int low, int high,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 16

Multiple choice Sorting And Searching
public void process(int[] a) { for (int i = 1; i < a.length; i++) // Line 1 { int current = a[i]; // Line 2 int j = 0; // Line 3 while (a[j] < current) // Line…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 17

Multiple choice Sorting And Searching
public void process(int[] a) { for (int i = 1; i < a.length; i++) // Line 1 { int current = a[i]; // Line 2 int j = 0; // Line 3 while (a[j] < current) // Line…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 18

Multiple choice Sorting And Searching
Consider the following method. /** Returns the index of searchVal, if found in list; * otherwise returns -1 */ public int binarySearch (ArrayList<String> list,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 19

Multiple choice Sorting And Searching
How does a standard…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 20

Multiple choice Sorting And Searching
True or false: linear search becomes…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 11 of 139
Page 2 of 14