Intermediate · Module 16 · Lesson 4

Jump & reachability

Track the farthest achievable frontier.

15–25 min readLesson 92 of 123

Lesson 92 of 123

1d streak

Theory lesson · Step-by-step

Understand Jump & reachability

Track the farthest achievable frontier.

Worked approach

Trace the reasoning step by step

  1. 1State the candidate ordering and local choice made by Jump & reachability.
  2. 2Identify the feasibility condition maintained by the partial solution.
  3. 3Use an exchange or stays-ahead argument to justify the choice.
  4. 4Commit the choice and remove candidates it makes impossible.
  5. 5Search for a counterexample before trusting the greedy rule.

Concrete example

Can [2,3,1,1,4] reach the last index?

  1. 1From index 0, farthest is 2.
  2. 2Index 1 extends farthest to 4.

The last index is reachable.

What must remain true (Loop Invariant)

After every choice in Jump & reachability, the partial solution can still be extended to an optimum under the proved exchange or stays-ahead argument.

Cost Model

Complexity & Trade-offs

Farthest-frontier scan
O(n)
O(1)
The bound follows from the number of states visited and the work performed per transition.

When to use it

  • Scheduling, reachability, coding, matching resources, and minimum-cost growth.
  • Problems with an exchange proof or matroid-like safe choices.
  • Online decisions that maintain a best frontier.

Common mistakes

  • Choosing a plausible local optimum without a proof.
  • Using the wrong sorting key.
  • Applying greedy reasoning when choices interact through future state.

Practice prompts

  • Reproduce the worked Jump & reachability example without looking at the trace.
  • Change one input condition and explain whether the Jump & reachability invariant still holds.
  • Implement the approach, derive its cost, and compare it with a straightforward baseline.

Mastery check

Can you derive it instead of memorizing it?

State the invariant before looking at code.
Explain why every transition is safe.
Construct a worst-case input.
Name one alternative and its trade-off.