Original array in place in time nk log

Assignment Help Macroeconomics
Reference no: EM131214730

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.).

Reference no: EM131214730

Questions Cloud

Where do the voltage maxima and minima in occur : Application: Standing wave ratio and minima and maxima on the line. For a line with characteristic impedance Z0 = 50 Ω and a load R = 220 Ω
Find the pm : Highway A and Highway B merge to form Highway C - Find the PM.-  Is also a Poisson random varialbe or does it follow some other distribution?
What are the uses of context free grammars : What are the uses of Context Free Grammars? What are the applications of Context Free Languages?
Find the maximum and minimum voltage on the line : If the voltage at the load is 100 V, find the maximum and minimum voltage on the line.
Original array in place in time nk log : 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].
Identify various social trends that affect marketing : To complete this assignment, students must prepare a real-world marketing news example, event, or success story and communicate it to the class. Students should use popular resources such as The Wall Street Journal, Bloomberg Businessweek, Inc., e..
Analyse principles and trends in performance : Performance Management and Control - Identify and critically analyse principles and trends in Performance Measurement and Control and Determine the different budgeting techniques and critically evaluate their use in short term decision making
What mechanism is responsible for the formation of products : If k1 > k2, is the overall reaction SN1 or SN2? Research and Explain what chemical mechanism is responsible for the formation of the products.
Calculate and plot the line impedance as a function : At the frequency at which the line operates, the reactance of the load is -j50 Ω and the phase constant on the line is 20π rad/m. Calculate and plot the line impedance as a function of distance from load.

Reviews

Write a Review

Macroeconomics Questions & Answers

  If marginal product is above the average product what will

If marginal product is above the average product, what will be effect on total product, total revenue,average product and average variable costs?

  Find the equilibrium rate of return

Assume the market can be described through the following three sources of systematic risk with associated risk premiums.

  Problems of international terrorism and terrorist groups

Based on the different approaches to international relations (from Chapter 12) how do has the US designed their response to the problems of international terrorism and terrorist groups (such as ISIS)?

  Google in mobile phone software

Explain how network effects are largely responsible for the large market shares enjoyed by Microsoft in desktop operating systems and by Google in mobile phone software.

  Why do economists pay more attention to national economies

Discuss the differences between unemployment and underemployment and give examples of each. Include in your contribution the differences between fiscal and monetary policy and how each would be used to reduce high levels of unemployment.

  What you think are the normative implications of the article

Find a recent newspaper editorial on monetary policy, interest rates, or macroeconomics and give the title of the article, date, source and columnist name if applicable - what you think are the normative implications of the article.

  Keller graduate school of management

Keller Graduate School of Management Database Concepts Class, please research the ODBC standard and the uses of ODBC. What is the difference between ODBC and OLE DB?

  Arise in u.s. inflation causes many u.s. residents to buy

Arise in U.S. inflation causes many U.S. residents to buy gold, which is a major South African export good, as a hedge against inflation.

  Brief essay describing the policy you will be analyzing

How does policy fit into the current macro context and what are the likely effects of this policy on the components of aggregate demand, and on equilibrium output?  Specificity and detail are key in describing policies and their effects.

  Can you think of reasons for this contrast

In contrast, such changes became frequent in the interwar period. Can you think of reasons for this contrast?

  Concerns in the absence of government intervention

What can we as private individuals do to address these concerns in the absence of government intervention? Are such private solutions likely to be effective?

  Explains the country with a fixed or managed exchange rates

This problem from economics, mainly to macroeconomics and it is explains the country with a fixed or managed exchange rate would consider i.___ its currency to gain competitive advantage vis-a-vis its trade partners. ii. Briefly Explain?

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