Workspace IndexDev Notes › Amortized analysis via potential functions

#215PoC

Amortized analysis via potential functions

Proving O(1) amortized cost for dynamic-array doubling with a potential function.

Algorithms — from 2026-08-03's advanced dev-knowledge track (Day 1/100).

Why

A core algorithms-interview topic: proving that an operation with occasional expensive worst cases (like a dynamic array's resize-and-copy) is still O(1) on average over a sequence of operations, using the potential-function accounting method rather than a hand-wavy argument.

How it works

Planned: an interactive dynamic array (a growable vector) where each push is logged with its real cost, alongside a running potential function Φ that tracks "banked" cost from cheap operations — demonstrating that amortized cost = real cost + ΔΦ stays bounded even across a resize. Not yet built.

← All Dev Notes · Workspace Index · Top ↑

포텐셜 함수를 이용한 분할상환 분석

포텐셜 함수로 동적 배열 2배 증가의 분할상환 비용이 O(1)임을 증명.

알고리즘 — 2026-08-03 매일의 개발 지식 100 트랙 (Day 1/100).

알고리즘 면접의 핵심 주제 중 하나입니다: 동적 배열의 resize-and-copy처럼 가끔 비싼 최악의 경우가 있는 연산이라도, 일련의 연산 전체로 보면 평균 O(1)임을 대충 넘어가는 논증이 아니라 포텐셜 함수 회계 기법으로 엄밀하게 증명합니다.

동작 방식

계획: 각 push 연산의 실제 비용을 기록하는 인터랙티브 동적 배열(확장 가능한 벡터)을 만들고, 저렴한 연산에서 "적립된" 비용을 추적하는 포텐셜 함수 Φ를 함께 보여줍니다 — 분할상환 비용(= 실제 비용 + ΔΦ)이 resize가 일어나는 순간에도 항상 일정 범위 안에 머무름을 증명합니다. 아직 미구현.

← 전체 개발 노트 · 워크스페이스 인덱스 · 맨 위 ↑