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 61–70 of 139
  1. 61
  2. 62
  3. 63
  4. 64
  5. 65
  6. 66
  7. 67
  8. 68
  9. 69
  10. 70

Question 61

Multiple choice Sorting And Searching
What is y after int y=binSearch(4)? private int[] a; // Precondition: a is sorted in ascending order. public int binSearch(int key) { int low=0,high=a.length-1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 62

Multiple choice Sorting And Searching
If the condition changes to low<high, which listed existing value is missed? private int[] a; // Precondition: a is sorted in ascending order. public int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 63

Multiple choice Sorting And Searching
After each unsuccessful iteration of binSearch, which is a safe loop invariant? private int[] a; // Precondition: a is sorted in ascending order. public int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 64

Multiple choice Sorting And Searching
A successful binary search on about30000 sorted elements must be…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 65

Multiple choice Sorting And Searching
For [1,7,9,5,4,12], what is the result after the third outer-loop pass? private Integer[] a; public void insertionSort() {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 66

Multiple choice Sorting And Searching
Which input requires the fewest executions of a[j+1]=a[j] while sorting descending? private Integer[] a; public void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 67

Multiple choice Sorting And Searching
Which input requires the most executions of a[j+1]=a[j] while sorting descending? private Integer[] a; public void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 68

Multiple choice Sorting And Searching
The programmer removes j>=0 from the while condition. For a nonempty array with at least two nonnull entries, which conditions independently guarantee that the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 69

Multiple choice Sorting And Searching
For nearly descending data, which is a valid general reason to prefer descending insertion sort to standard selection sort? I: insertion sort…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 70

Multiple choice Sorting And Searching
For large randomly ordered arrays, which is a valid asymptotic advantage of standard merge sort over…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 61 of 139
Page 7 of 14