An online computer system for trading stocks needs to process orders of the form buy 100 shares
Question:
An online computer system for trading stocks needs to process orders of the form “buy 100 shares at $x each” or “sell 100 shares at $y each.” A buy order for $x can only be processed if there is an existing sell order with price $y such that y ≤ x. Likewise, a sell order for $y can only be processed if there is an existing buy order with price $x such that y ≤ x. If a buy or sell order is entered but cannot be processed, it must wait for a future order that allows it to be processed. Describe a scheme that allows buy and sell orders to be entered in O(logn) time, independent of whether or not they can be immediately processed.
StocksStocks or shares are generally equity instruments that provide the largest source of raising funds in any public or private listed company's. The instruments are issued on a stock exchange from where a large number of general public who are willing...
Step by Step Answer:
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser