Jane Street–styleAnalystQuantitative AnalystQuestion #607
Design a heap data structure that supports adding elements and removing the top element, with the following constraints: (1) The topmost element must always be less than the topmost element in the left and right child subtrees; (2) The left child subtree must have as many or one more element than the right child subtree. The heap should also support a 'min' function (returns the value at the top of the tree) and an 'empty' function (returns an empty tree). Provide a description and implementation of such a data structure.
Build Your Approach
State the assumptions, try a simple case, then work toward a general solution. Check the result and explain how it changes if an assumption changes.
Try the free diagnostic with worked solutions →Get Free Interview Prep Resources
More Jane Street–Style Analyst Questions
You are given two identical eggs and a 100-story building. Your task is to determine the highest floor from which you can drop an egg without it breaking.How can you invert a pyramid of coins by moving only three coins?You flip a fair coin repeatedly and stop flipping after three heads in a row occur. What is the expected number of flips required?How many handshakes occur if every person in a room shakes hands with every other person exactly once?Given that the probability it rains on Sunday is 40% and the probability it rains on the weekend (Saturday or Sunday) is 60%, what is the probability it rains on Saturday?
Practice the Reasoning Behind the Answer
Bring your target roles and interview timeline to a free quant consult. Discuss your preparation priorities and how Quant Blueprint’s lessons, practice and mock interviews can help.
Book a Free Quant ConsultYour goals · your preparation · your next steps