Stacks and queues with amortized logarithmic-time operations
summary
Claims functional stacks and queues that store elements in arrays with doubling and Okasaki-style implicit queues, achieving storage of n words plus O(log n) overhead and amortized O(log n) per operation instead of O(1). Uses a zero-less redundant digit system (digits 1,2,3) where digit 2 is safe and a lazy-evaluation debit invariant to make persistence-safe amortization. Queue version keeps a front and rear digit per node and uses a shift operation combining carry and borrow to restore safety; extends to deques and input/output-restricted variants.
AI-written summary · about
