Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Macroeconomics Expert

1. Acme company buys and sells oil futures over the Internet. Its trading system receives buy orders from customers that seek to buy from the company. Each order has a bidding price. Orders may be deleted by the customer at any point in time and new orders may also come in at any time.The trading desk would like you to implement a system that keeps track of the top 100 highest buy orders at any point in time.You decide to build a data structure that has two parts: Minheap M of the top 100 orders, and a maxheap H that stores the remaining orders. The contents of the minheap are then displayed to the trading desk, whenever demanded.You are allowed heap operations: (a) min(M): returns the minimum element of a minheap M,(b) max(H): returns the maximum element of maxheap H, (c) insert(G,x): insert the element x in heap G and (d) delete(G,i): delete the ith element G[i] from heap G.Write down pseudocode for how you would update the M and H, under the following situations.Also, write down the worst-case running time in terms of the number of orders n that are currently active. You can assume for simplicity that n 100.

(A) A new order with price $B arrives. (Hint: You will first have to decide if the price is a top 100 price or not. Based on that you have to perform the appropriate heap operations).

(B) The top 100 order M[i] is withdrawn by the customer

2. An array is almost k sorted if every element is no more than k positions away from where it would be if the array were actually sorted in an ascending order.

(A) Write down pseudo code for an algorithm that sorts the original array in place in time nk log(k).Your algorithm can use a function sort(A, l, r) that sorts the subarray A[l], . . . , A[r].

(B) Suppose you are allowed extra array of size k + 1 on the side. Modify heap sort using a minheap of size k + 1, to sort the given array in time n log(k). (Hint: Take the first k + 1 elements and make a min heap. Keep extracting the minimum element from this min heap and adding anew element from the original array.).

Macroeconomics, Economics

  • Category:- Macroeconomics
  • Reference No.:- M91970713
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Macroeconomics

Question positions on whether the constitution should be

Question: Positions on whether the Constitution should be amended to require a balanced budget reflect opposing views about whether such an amendment would be an appropriate solution to the problem of persistent federal ...

Question explain these questionscompare the marginal

Question: Explain these questions Compare the Marginal Revenue Curve for a firm in the PC-market with the Marginal Revenue Curve for the monopolist. Explain in your own words why a company that creates a negative externa ...

Please answer the following four discussion questions1

Please Answer The Following Four Discussion Questions 1. Explain four types of unemployment 2. Explain the advantages and disadvantages of: (a) A flexible exchange rate regime (b) A fixed exchange rate regime 3. Suppose ...

Question - explain why it is important to evaluate the

Question - Explain why it is important to evaluate the overall performance of the firm's sales force and list the advantages and disadvantages of sales, cost, and profit analyses. Also, discuss the use of ROI in measurin ...

Question scenario imagine you are a business consultant to

Question: Scenario: Imagine you are a business consultant to a Business. You have been asked to analyze, advise, and create recommendations on how the firm can ensure its future success in its current market. Prepare a m ...

Question you will submit your answers in a blackboard

Question: You will submit your answers in a Blackboard assessment filling out charts and answering the essays/short answer questions. Note: There is not an option to upload your assignment, you must use the Blackboard as ...

Question firm 1 must decide whether to enter an industry in

Question: Firm 1 must decide whether to enter an industry in which firm 2 is an incumbent. To enter this industry, firm 1 must choose to build either a plant with a small output capacity (S), or large output capacity (L) ...

Question there is a buyer and a seller the buyer has a

Question: There is a buyer and a seller. The buyer has a valuation 40 for a usable product. The seller has a cost 0 of producing a bad product and a cost 20 of producing a good product. The sequence of events is as follo ...

Question explain which direction the below referenced

Question: Explain which direction the below referenced supply or demand curve will shift AND comment on the impact of the shift on equilibrium price and quantity. a) John, who is a clothing producer, now has to pay more ...

Question president trump has proposed a lowering of the

Question: President Trump has proposed a lowering of the corporate income lax rale from 35% to 15% and the top personal income tax rate from 39.6% to 15%. When lie unveiled the tax plan. Treasury Secretary Steven Mnuchin ...

  • 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