Hi, Im learning about amortized analysis and am not sure what accounting method is for b). Could
Fantastic news! We've Found the answer you've been seeking!
Question:
Hi, Im learning about amortized analysis and am not sure what accounting method is for b). Could you provide an example of accounting method or any hints on how to get started?
Transcribed Image Text:
2. [14] Suppose that we have an array A[1,2,...] (index starting at 1) that is sufficiently large, and supports the following two operations INSERT and PRINT-AND-CUT (where k is a global variable initially set to 0): 1 def INSERT (x): 2 k = k + 1 3 A[k] = 4 5 def 6 7 8 PRINT-AND-CUT (): for i from 1 to k: print A[k] k = k // 2 # integer division We define the cost of the above two operations as follows: The cost of INSERT is exactly 1. • The cost of PRINT-AND-CUT is exactly the value of k before the operation is executed. Now consider any sequence of n of the above two operations. Starting with k = 0, perform an amortized analysis using the following two techniques. (a) Use the aggregate method: First, describe the worst-case sequence that has the largest possible total cost, then find the upper-bound on the amortized cost per operation by dividing the total cost of the sequence by the number of operations in the sequence. (b) Use the accounting method: Charge each inserted element the smallest amount of "dollars" such that the total amount charged always covers the total cost of the operations. The charged amount for each insert will be an upper-bound on the amortized cost per operation. 2. [14] Suppose that we have an array A[1,2,...] (index starting at 1) that is sufficiently large, and supports the following two operations INSERT and PRINT-AND-CUT (where k is a global variable initially set to 0): 1 def INSERT (x): 2 k = k + 1 3 A[k] = 4 5 def 6 7 8 PRINT-AND-CUT (): for i from 1 to k: print A[k] k = k // 2 # integer division We define the cost of the above two operations as follows: The cost of INSERT is exactly 1. • The cost of PRINT-AND-CUT is exactly the value of k before the operation is executed. Now consider any sequence of n of the above two operations. Starting with k = 0, perform an amortized analysis using the following two techniques. (a) Use the aggregate method: First, describe the worst-case sequence that has the largest possible total cost, then find the upper-bound on the amortized cost per operation by dividing the total cost of the sequence by the number of operations in the sequence. (b) Use the accounting method: Charge each inserted element the smallest amount of "dollars" such that the total amount charged always covers the total cost of the operations. The charged amount for each insert will be an upper-bound on the amortized cost per operation.
Expert Answer:
Answer rating: 100% (QA)
Answer a In the aggregate method amortized cost of a operations must be an upper bound the actual co... View the full answer
Related Book For
Entrepreneurship Successfully Launching New Ventures
ISBN: 978-0133797190
5th edition
Authors: Bruce R. Barringer, R. Duane Ireland
Posted Date:
Students also viewed these electrical engineering questions
-
Provide an example of an experiment or data that has two factors. Provide details (what is being measured and the number of levels) of the levels for factor A and factor B.
-
Provide an example of a fixed cost that would be relevant to a make-or-buy decision, and an example of a fixed cost that would not be relevant to such a decision.
-
Provide an example of how general economic trends would affect sales forecasting in the airline industry.
-
The technique of performance management that establishes and monitors four dimensions of performance: Question 11Answer a. Profit, sales, productivity, and asset management performance b. Financial,...
-
An engineer at Delphi Systems is considering the projects below, all of which can be considered to last indefinitely. The company's MARR is 13% per year. (a) Determine which projects should be...
-
We need to upgrade a channel to a higher bandwidth. Answer the following questions: a. How is the rate improved if we double the bandwidth? b. How is the rate improved if we double the SNR?
-
Haupt Consulting, Inc., began operations and completed the following transactions during the first half of December: Requirements 1. Analyze the effects of Haupt Consultings transactions on the...
-
The village of Fay was recently incorporated and began financial operations on July 1, 2018, the beginning of its fiscal year. The following transactions occurred during this first fiscal year from...
-
Tamarisk Inc. incurred a net operating loss of $509,000 in 2020. The tax rate for all years is 20%. Prepare the journal entries to record the benefits of the loss carryforward. Tamarisk expects to...
-
TourneSol Canada, Ltd. is a producer of high quality sunflower oil. The company buys raw sunflower seeds directly from large agricultural companies, and refines the seeds into sunflower oil that it...
-
Marvin Ltd had the following inventory balances at the beginning and end of December December 1 December 31 Raw materials $27,400 $59,000 Finished Goods $89,200 $93,600 Work in Process $27,400...
-
A painting with a mass of 21 kg is suspended by two wires from hooks on a ceiling. if the wires have lengths of 21 cm and 30 cm and the distance between the hooks is 35 cm , find the tension in each...
-
answer this question in Java and only if you are fully confident of the answer. The code should work without any errors. These are not stocks, but transactions that have occurred. Cashback value can...
-
Question 1 (20P) When the single-index model is used, the variance of a security's return is expressed as: o = o +0 Derive the equation above for the variance security's return by using the...
-
Frank gave Betty real estate with a basis of $100,000 and marketable securities with a basis of $20,000. In exchange, Betty gave Frank real estate with a basis of $240,000 and worth $300,000. The...
-
3. Consider the stratified fluid depicted below which is being sheared between two infinite parallel plates. If the upper plate is constrained to move with velocity U, the lower plate is fixed, and...
-
The purpose of this training program is to address the specific training issue in the printing area our small company, where production has declined after the recent hiring of new employees. The...
-
The text defined intrinsic value as the value of an asset given a hypothetically complete understanding of the assets investment characteristics. Discuss why hypothetically is included in the...
-
Spend some time studying Patagonia, by looking at the companys Web site and its Facebook page, and via other Internet searches. Describe Patagonias general approach to business ethics, social...
-
To what degree is there a difference between pursuing an opportunity to solve a problem and building a business? In what ways did Everpix fail to do both?
-
What risks do small firms face when partnering with large, successful companies? What risks do large companies take when they partner with small start-ups?
-
You have been approached by promoters to give an opinion on the financial statements to be included in the prospectus of a proposed corporation to be named U-Park Corporation. U-Park will own and...
-
The following questions relate to the auditor's responsibility for reporting on inconsistency of application of accounting principles. Select the best response. a. Raider uses the last-in, first-out...
-
J.O. Cole, a sole proprietor, operates a trucking business. Cole also has assets and liabilities in connection with other activities. You are retained to audit the accounts of the J.O.C. Truck Lines...
Study smarter with the SolutionInn App