About this question

Order Book Data Structure

Medium · Number Theory & Algorithms · Quant Trader interview question · data-structures, algorithms, order-book, trading, hashmap, treemap

You are building an order book for a high-frequency trading system. The order book needs to efficiently support the following operations: 1. Insertion: Adding new orders at specific price levels. 2. Best Bid/Ask Retrieval: Quickly finding the highest bid price and the lowest ask price. Price levels are represented as keys. You are considering using either a HashMap or a balanced Binary Search Tree (BST), such as a TreeMap, to store the price levels and their corresponding orders. Why is a bala