AP Computer Science A Resource

Algorithms practice guide

A connected AP Computer Science A algorithm map for searching, sorting, recursion, array/list processing, and String manipulation.

Study Snapshot

AP unit

Units 2 and 4

Exam use

Search, sort, recursion, array/list processing, and runtime reasoning

Study time

60-75 min

Best used when

Students preparing for mixed-topic MCQs and FRQs where algorithm patterns are combined.

Linear search works on unsorted data
Binary search requires sorted data
Selection and insertion sort are O(n^2)

Sorting

AP Computer Science A expects students to recognize selection sort, insertion sort, and merge sort behavior.

+

Selection sort repeatedly chooses the next smallest value.

+

Insertion sort inserts each item into the sorted left side.

+

Merge sort divides, sorts, and merges.

+

Compare algorithms by trace behavior, not only by names.

Recursion and Processing

Recursive algorithms need a base case, a smaller call, and a meaningful return path.

+

Every recursive method needs a reachable base case.

+

The recursive call should move toward that base case.

+

Array and String algorithms often combine traversal with accumulation.

+

Runtime reasoning helps students compare simple loops, nested loops, and divide-and-conquer methods.

public static int sum(int n) {
  if (n == 0) {
    return 0;
  }
  return n + sum(n - 1);
}

Practice checklist

Use these prompts as a short self-check before moving back into FRQs or class assignments.

Trace binary search on a sorted array and record low, mid, and high each pass.
Write selection sort for an int array.
Write a recursive method that counts down by 2.
Compare a nested-loop algorithm with a single-loop algorithm using Big-O language.

For practice use only.

AP Computer Science A Algorithms Hard MCQ Practice

Practice hard AP Computer Science A searching, sorting, loop-boundary tracing, comparison counts, algorithm correctness, runtime intuition, and array/list mutation.

Question 1 of 25

Answered 0 of 25

Choose one answer.

What value is returned by search(data, 4)?

public static int search(int[] data, int target) {
  for (int i = 0; i < data.length; i++) {
    if (data[i] == target) {
      return i;
    }
  }
  return -1;
}

int[] data = {4, 2, 4, 1};

Need help applying this?

Bring this topic into your next AP Computer Science A session.

Schedule Free Consultation