A tick-by-tick price feed, an order book, and a backtest's rolling window of returns are all, underneath the finance vocabulary, sequences: ordered collections you append to, read from, and occasionally trim. The single most consequential design decision for any such sequence — before a single line of pricing logic is written — is whether to store it as a contiguous array or as a linked list, because that choice fixes the cost of every operation you will ever run on it. This note builds the operation-cost table for both, then layers the stack and queue abstract data types (ADTs) on top, since both can be realised by either representation and each realisation has different trade-offs. Getting this right matters concretely: implementing a limit-order book's price levels as the wrong structure turns an insert into an one, and at high message rates that difference is the difference between a system that keeps up and one that doesn't.
In this lesson
- Learning objectives
- Arrays: contiguous memory, index arithmetic
- Linked lists: pointers, not addresses
- Stacks: last-in, first-out
- Queues: first-in, first-out
Before you start
The full lesson, with worked examples and exercise solutions, is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or explore the curriculum.