Skip to content

Commit 6a17d83

Browse files
author
Hamid Gasmi
committed
Amortized Analysis section is updated
1 parent 8afb1bd commit 6a17d83

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,13 @@
770770
- `Φ(h0) = 2 × 0 − 0 = 0`
771771
- `Φ(hi) = 2 × size − capacity > 0` (since size > capacity/2)
772772
- Calculating Amortized cost for operation i (adding element i): `ci + Φ(hi) − Φ(hi−1)`:
773-
-Without resize:
774-
ci = 1;
773+
- Without resize:
774+
- ci = 1;
775775
Φ(hi) = 2 * (k + 1) - c
776776
Φ(hi-1) = 2 * k - 2 - c
777777
ci + Φ(hi) − Φ(hi−1) = 1 + 2 * k - c - 2 * k + 2 + c = +3
778778
- With resize:
779-
ci = k + 1;
779+
- ci = k + 1;
780780
Φ(hi) = 2 * (k + 1) - 2 * k = 2 since there is a resize, the array capacity is doubled
781781
Φ(hi-1) = 2 * k - k = k since before the resize, the array capacity is equal to the array size
782782
ci + Φ(hi) − Φ(hi−1) = k + 1 + 2 - k = +3

0 commit comments

Comments
 (0)