Arithmetic Series
Context: FIT1008_MOC, FIT1058_MOC, FIT2004_MOC · the sum of an arithmetic sequence · the counting tool behind nested-loop Time Complexity FIT2004 use: the behind shrink-by-one recurrences () and behind sorted insertions into a BST.
Quick Revision
- 🎯 Objective: sum a constant-difference sequence ➔ (average of first and last term).
- 📦 Core Components: general ➔ the case.
- ⚡ Key Constraint: ➔ why a “shrinking” nested loop is quadratic, not linear.
📝 Core
1. The Series (Constant Difference)
- General sum ➔ from first term , terms: .
- Algorithm-analysis case ➔ .
- Gauss pairing ➔ , over pairs.
2. Reverse-and-Add (FIT1058)
- Method ➔ write forwards and backwards, aligned ➔ every column sums to .
- Result ➔ .
- Dominant term ➔ linear, quadratic ➔ sign of decides .
3. Which Series a Loop Generates
- Arithmetic ➔ nested loops whose inner count shrinks by one.
- Geometric ➔ Binary Tree node counts, height.
⚖️ Core Decision Matrix
| Sum | Closed form | Order |
|---|---|---|
| (Geometric Series) | ||
When It Flips: the constant and lower-order drop under Big-O Notation, leaving — but the exact closed form is needed for tight constants or off-by-one correctness.
📊 Exam Execution Trace
Manual Execution Trace
Counting a shrinking nested loop, :
| Step / State | Outer pass | Inner iterations | Running total |
|---|---|---|---|
| 0 (Init) | — | — | 0 |
| 1 | 1 | 4 | 4 |
| 2 | 2 | 3 | 7 |
| 3 | 3 | 2 | 9 |
| 4 | 4 | 1 |
⚠️ Common Mistakes
- 💡 Shrinking inner count is still ➔ not ; a sum of terms each averaging is quadratic.
✍️ Practice
Practice 1: Prove for by induction.
- Hint: In the step, add and factor it out.
Answer
- Basis (): LHS ; RHS . ✓
- Hypothesis: assume for some .
- Step: which is the claim at .
- Short answer: basis and step hold ⟹ true for all . Q.E.D.
- Why: Factor, don’t expand ➔ pulling out lands the target form directly; multiplying out to then re-factoring is the same work done twice.
🧠 Active Recall
A nested loop's inner count shrinks by one each pass — why is it , not , and what is the exact count?
- Hint: A shrinking sum is still quadratic.
Answer
- Short answer: Total iterations .
- Why: Averaging ➔ terms each averaging ⟹ quadratic, even though no single pass does work.
Match each series to the algorithm class it powers: arithmetic vs geometric.
- Hint: Series shape ↔ cost shape.
Answer
- Short answer: Arithmetic → quadratic sorts; geometric → tree node counts / height.
- Why: Loop geometry ➔ linear-shrink inner loops sum arithmetically; branching structures sum geometrically.
When is the closed form needed rather than just the order?
- Hint: Constants and off-by-one.
Answer
- Short answer: For exact constants, tight proof bounds, or off-by-one loop reasoning.
- Why: Order hides constants ➔ two algorithms differ by leading coefficient; whether a sum runs to or changes the exact count.