Off-By-One Binary Search Bug - Quant Trader Interview Question
Difficulty: Medium
Category: Code Analysis
Practice quant interview questions from top firms including Jane Street, Citadel, Two Sigma, DE Shaw, and other leading quantitative finance companies.
Topics: binary-search, off-by-one, bug-identification, algorithms
Problem Description
You are tasked with reviewing a binary search implementation used in a high-frequency trading system. The system searches for the optimal price point within a sorted array of potential prices. However, under certain conditions, the binary search gets stuck in an infinite loop, causing the system to miss trading opportunities.
Here is the Python code:
Identify the bug in the code that leads to the infinite loop.
Practice this medium trader interview question on MyntBit - the all-in-one quant learning platform with 200+ quant interview questions for Jane Street, Citadel, Two Sigma, and other top quantitative finance firms.