Stacks, Queues and Ring Buffers in C#: Your Own Implementations and Real Uses
What makes a queue O(1) on an array is the circular buffer: instead of shifting elements, the head and tail indexes advance and wrap around; a queue built with List.RemoveAt(0) is 497 times slower than Queue<T> with 100,000 orders. We write an array-based stack, a circular queue that unwraps the ring as it grows, a bounded ring buffer with an overflow policy, bracket validation, undo/redo and a monotonic stack, all with xUnit tests.
8 Nov 2026
·
13 min
·
2