Before a quant system can search, rank, or join data at scale, it needs a small set of building blocks whose costs are known exactly: a way to store an ordered sequence and grow it cheaply, a way to look values up by key in expected constant time, and a family of sorting algorithms whose or better costs make every "sort then process" pipeline tractable. This topic builds all of it: arrays, linked lists, stacks, and queues as the linear-structure vocabulary; the doubling strategy and amortized analysis that explain why a growable array is still per append despite occasional expensive resizes; hash tables for expected- keyed lookup; heapsort and the heap data structure it introduces (reused immediately as a priority queue); quicksort, whose worst case motivates randomization, reusing Topic 1's indicator-variable machinery directly; linear-time sorting for when comparisons can be avoided; and order statistics (quickselect) for when only a rank, not a full sort, is needed. This is the deepest topic in the unit because it is where a quant reader's daily toolkit — the operations
list.append, dict[key], sorted(...), heapq.heappush — gets its cost guarantees derived from first principles rather than taken on faith.By the end of this topic you should be able to:
- choose between an array-backed and a linked-list-backed structure based on the operation-cost table each supports;
- prove a dynamic array's amortized append using the aggregate, accounting, or potential method;
- analyse a hash table's expected search cost under simple uniform hashing, and choose between chaining and open addressing;
- implement and analyse heapsort, quicksort (and its randomized variant), and the three linear-time sorts, stating each one's cost and when it applies;
- solve the selection problem in expected linear time via quickselect.
In this lesson
- Contents
- The big picture
The full lesson is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or explore the curriculum.