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: ; the term is linear, quadratic, and the sign of decides .
- Algorithm-analysis case ➔ .
- Gauss pairing ➔ , over pairs.
2. Reverse-and-Add (FIT1058)
- Method ➔ write forwards and backwards, aligned ➔ every column sums to ⟹ .
3. Which Series a Loop Generates
- Arithmetic ➔ nested loops whose inner count shrinks by one (quadratic sorts).
- Geometric ➔ Binary Tree node counts, branching structures ➔ Geometric Series.
⚖️ 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 (whether a sum runs to or changes the count).
📊 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 ; terms each averaging is quadratic, even though no single pass does work.
✍️ 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; expanding to then re-factoring is the same work twice.
🧠 Active Recall
Match each series to the algorithm class it powers: arithmetic vs geometric.
- Hint: Series shape ↔ cost shape.
Answer
- Short answer: arithmetic → quadratic sorts and shrink-by-one recurrences; geometric → tree node counts / height.
- Why: Loop geometry ➔ linear-shrink inner loops sum arithmetically; branching structures sum geometrically.