1. Consider amortized cost for the scenario where we have a stack such that: A...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Consider amortized cost for the scenario where we have a stack such that: • A pop costs 1. . A push costs 1, not counting any allocation that may be necessary. • Re-allocation costs the new size. This cost includes copying the contents of the old stack. Assume we start with 0 bytes allocated and when we re-allocate we multiply the length by a € Z where a ≥ 2 except for the very first re-allocation which goes from 0 to 1. Define: f(a) - a² + a-1 a - 1 (a) Use the aggregate method to prove that in the worst case with n operations the amortized [25 pts] cost AC (n) of each stack operation satisfies AC(n) ≤ f(a). (b) Prove mathematically that this expression is minimum when a = 2. [15 pts] 1. Consider amortized cost for the scenario where we have a stack such that: • A pop costs 1. . A push costs 1, not counting any allocation that may be necessary. • Re-allocation costs the new size. This cost includes copying the contents of the old stack. Assume we start with 0 bytes allocated and when we re-allocate we multiply the length by a € Z where a ≥ 2 except for the very first re-allocation which goes from 0 to 1. Define: f(a) - a² + a-1 a - 1 (a) Use the aggregate method to prove that in the worst case with n operations the amortized [25 pts] cost AC (n) of each stack operation satisfies AC(n) ≤ f(a). (b) Prove mathematically that this expression is minimum when a = 2. [15 pts] 1. Consider amortized cost for the scenario where we have a stack such that: • A pop costs 1. . A push costs 1, not counting any allocation that may be necessary. • Re-allocation costs the new size. This cost includes copying the contents of the old stack. Assume we start with 0 bytes allocated and when we re-allocate we multiply the length by a € Z where a ≥ 2 except for the very first re-allocation which goes from 0 to 1. Define: f(a) - a² + a-1 a - 1 (a) Use the aggregate method to prove that in the worst case with n operations the amortized [25 pts] cost AC (n) of each stack operation satisfies AC(n) ≤ f(a). (b) Prove mathematically that this expression is minimum when a = 2. [15 pts] 1. Consider amortized cost for the scenario where we have a stack such that: • A pop costs 1. . A push costs 1, not counting any allocation that may be necessary. • Re-allocation costs the new size. This cost includes copying the contents of the old stack. Assume we start with 0 bytes allocated and when we re-allocate we multiply the length by a € Z where a ≥ 2 except for the very first re-allocation which goes from 0 to 1. Define: f(a) - a² + a-1 a - 1 (a) Use the aggregate method to prove that in the worst case with n operations the amortized [25 pts] cost AC (n) of each stack operation satisfies AC(n) ≤ f(a). (b) Prove mathematically that this expression is minimum when a = 2. [15 pts]
Expert Answer:
Answer rating: 100% (QA)
To address this question lets start by breaking it down into two parts as the question has two separate sections part a and part b Part a Aggregate Method for Amortized Cost We are given a stack with ... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
The textile company produces the article PCR5, through two production departments A and B. to account for its production costs, it uses the standard cost system. The standard specification time...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In an organization, leaders treat employees as ends when they ______. Multiple choice question. restrict employees' choices allow employees to create their own purposes assume that the employees'...
-
Elina Siljander owns Elinas Stained Glass in Helsinki, Finland. The business produces and sells three different types of stained glass windows: small, medium, and large. Elina has two full-time...
-
For each of the following, select its best description. 1. Cost center 2. Profit center 3. Responsibility accounting system 4. Operating department 5. Indirect expenses 6. Controllable costs a....
-
Assume the unadjusted and adjusted trial balances for Milky Way Theater, Inc., at November 30, 2010, show the following data: Requirement 1. Journalize the adjusting entries that account for the...
-
A thin metallic wire of thermal conductivity k, diameter D, and length 2L is annealed by passing an electrical current through the wire to induce a uniform volumetric heat generation q. The ambient...
-
What is the ordering level for material A? (Material A and B are used as follows: Minimum usage- 10 units each per week Maximum usage- 30 units per week Normal usage - 20 units per week Ordering...
-
The Kentucky Derby is held the first Saturday in May at Churchill Downs in Louisville, Kentucky. The race track is one and one-quarter miles. The following table shows the winners since 2000, their...
-
Find the percentage change in price in each of the following examples using the mid-point method. Instructions: Round your answers to two decimal places. If you are entering a negative number be sure...
-
a transaction that transfers money from one bank account to another could lead to an inconsistent database state if it fails after withdrawing the money from first account, but before putting the...
-
1. Explain the difference between required rate of return and expected rate of return. If they are different at a specific point in time, what does it mean? 2. What is the difference between an...
-
Core Leadership 5.27 Adaptive Leadership 6.0 Emotional Intelligence 5.6 Based upon the above quiz scores, answer the following: Do you believe the scores and skill groups align with your behaviors...
-
Below is a bar graph that shows the advertising expenses of three different types of media; Print, Television and Social Media, for each year from Year 1 to Year 3. Expenses (Rs. Crores) 4500 4000...
-
A stunt man drives a car at a speed of 20 m/s off a 34-m-high cliff. The road leading to the cliff is inclined upward at an angle of 20. How far from the base of the cliff does the car land? Express...
-
a. 120.14 N/mm^2 b. 214.16 N/mm^2 c. 314.16 N/mm^2 d. 620.14 N/mm^2 Q.12 A thin high strength steel plate 4 mm thick and 1000 mm long is bent by couples Mo into a circular arc which subtends a...
-
Juarez worked for Westarz Homes at construction sites for five years. Bever was a superintendent at construction sites, supervising subcontractors and moving trash from sites to landfills. He...
-
Implement a stack using a singly linked list L. The operations PUSH and POP should still take O(1) time.
-
Show how OS-SELECT (T.root, 10) operates on the red-black tree T of Figure 14.1. Figure 14.1 26 20 17 41 E--- 12 7 14 21 30 47 -------- -------- E---- ----- --- 4 1 16 2 (14 (10 19 21 28 38 4 2 1 12...
-
Give an upper bound on the size of * [q] as a function of q. Give an example to show that your bound is tight.
-
On April 1, Caesar Salad Dressings creates a petty cash fund with an imprest balance of \(\$ 400\). During April, Elise Nelson, the fund custodian, signs the following petty cash tickets: On April...
-
Pendley Productions makes all sales on credit. Cash receipts arrive by mail. Larry Padgitt in the mailroom opens envelopes and separates the checks from the accompanying remittance advices. Padgitt...
-
Suppose that on June 1, Cool Gyrations, a disc jockey service, creates a petty cash fund with an imprest balance of \(\$ 300\). During June, Carol McColgin, fund custodian, signs the following petty...
Study smarter with the SolutionInn App