Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9886581

Have any Question?


Related Questions in Computer Engineering

What are the critical issues we must think about while

What are the Critical Issues we must think about while designing a Lexical Scanner? The results of that development, e.g., discuss both process and product.

Specifically you will create an e-commerce application

Specifically, you will create an e-Commerce application using PHP and HTML that allows a user to login to a website, select several products for purchase and then place an order for those items selected. The type of prod ...

What does it mean when a bank has lower derivative assets

What does it mean when a bank has lower derivative assets than derivative liabilities on foreign exchange related contracts and vice-versa? What implications does this have with foreign exchange risk for the bank?

Java program that does the following please use simple

Java program that does the following: Please use simple computer syntax. More easy to understand! Use a while loop to prompt the user to enter 10 rain falls. Calculate and output the total and the average rain fall. Find ...

You are studying the number of defective parts produced

You are studying the number of defective parts produced each week by several machines to help adjust maintenance protocols. Assume the rows of matrix Def represent different machines and all columns except the last repre ...

Question read a sentence with period at the end display the

Question: Read a sentence with period at the end. Display the sentence so that all vowels are in uppercase sample I/O Enter a sentence: proud is self-respect. Output: prOUd Is sElf-rEspEct. I have written a c++ code for ...

Question suppose jim is in a middle school band that is

Question : Suppose Jim is in a middle school band that is selling cookie dough. His mom sends emails to all the employees of her company (100 people), inviting them to stop by after work to place orders for the cookie do ...

A set of coins makes change fornbspnnbspif the sum of the

A set of coins makes change for n if the sum of the values of the coins is n. For example, if you have 1-cent, 2-cent and 4-cent coins, the following sets make change for 7: 7 1-cent coins 5 1-cent, 1 2-cent coins 3 1-ce ...

How does a java server page uses the client-server model to

How does a Java Server Page uses the client-server model to make a Web page interactive?

Question suppose that in a divide and conquer algorithm we

Question : Suppose that, in a divide and conquer algorithm, we divide an instance of size n of a problem into 16 sub instances of size n/4 and the dividing takes O(1) time (you may ignore this step). Then we combine the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As