Why your program should require o(logn) time per order

Assignment Help Basic Computer Science
Reference no: EM13307262

The double action system operates as follows. When a new buy order of $x arrives it is simply stored for future use if none of the stored sell orders has an asking price lower than or equal to $x. Otherwise, the new buying bid is matched with the sell order with lowest asking price (earliest such order if there are ties). The two matched orders are removed from the system, and the buyer receives the item in exchange for paying a clearing price equal to the matched sell order asking price, i.e., the lowest asking price available at the time the new buy order was received.

Processing of a new sell order with an asking price of $y is done in a similar way. If all stored buying orders have a bid price strictly lower than $y, then no matches can be made and the new order is simply stored for possible future matching. Otherwise, the new sell order is matched with the stored buy order with highest bid price, handling ties as above. The two matched orders are again removed from the system, and the clearing price paid in this case is the bid price of the matched buy order, i.e., the highest bid price available at the time the new sell order was received. your program should require O(logn) time per order when processing a list of n orders.

Sample Input 1

order 1 sell at 30
order 2 buy at 20
Output for Sample Input 1

units exchanged 0 total clearing price 0
Sample Input 2

order 1 sell at 30
order 2 buy at 20
order 3 buy at 40
order 4 buy at 30
order 5 sell at 10
Output for Sample Input 2

units exchanged 2 total clearing price 60

Reference no: EM13307262

Questions Cloud

Determine her metabolic power : For exercise, a 60 kg athlete runs up a 10-m high hill in 30 seconds. Assume the efficiency of the human body is 25%. Determine her metabolic power
How the typical sources of business growth : Speculate on how the typical sources of business growth might evolve over the coming decade. Explicate how these changes might affect businesses in the industry you have selected for this course. Support your speculations with examples and discuss wh..
Create a student class which will contain the following : Demonstrate the correct working of your classes by reading in a collection of student records from a file, sort the records, and print them. If a name is "EOF" it will mark the end of the file.
Derermine the velocity and acceleration of point p : At the same instant the frame h, not the horizontal blade, rotates about a vertical axis with a constant angular velocity w=0.9 rad/s, measured relative to h
Why your program should require o(logn) time per order : The double action system operates as follows. When a new buy order of $x arrives it is simply stored for future use if none of the stored sell orders has an asking price lower than or equal to $x.
Determine the time it takes for the light to strike ground : Falling light. According to general relativity and the equivalence principle, light is bent by gravity. Determine the time it takes for the light to strike the ground
What was the initial concentration of cocl2 : What was the initial concentration of COCl2?
Particle of mass m in a uniform gravitational field : Consider a particle of mass m in a uniform gravitational field. Its potential energy is E(h) = mgh,where h is the height above sea level and g is the earth's gravitational constant, g = 9:8 m/s2.
Determine the distance that a particle on the rim moves : The flywheel of a prototype car engine is under test. The angular position of the flywheel is given by x = (3.0rad/s3)t3 and the diameter of the flywheel is 36cm.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd