Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6602991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:56:49+00:00 2026-05-25T18:56:49+00:00

There is a sequence of n operations, The ith operation costs 2i if i

  • 0

There is a sequence of n operations, The ith operation costs 2i if i is an exact power of 2, costs 3i if i is an exact power of 3, and 1 for all other operations.

Hi first up I want to say that it is a homework problem and I don’t want you to solve it for me.

I have solved it using the aggregate method. For which I summed up the series of powers of 2 and series of powers of 3 and got amortized cost of 10. I then checked it using the accounting method, for really long sequences and it did not fail. But my problem is how to prove that it would never fail, I can show for as long sequence I want but it would still not guarantee that it would not fail some time after.

Also I tried solving it with the potential function method, this is where I am really stuck, to device a potential function I think you need to be really creative, I cant find some condition which states that at this point this would always hold, need some help there too.

Just some ideas about how to prove it in the accounting method and how to device a potential function should be enough.
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:56:49+00:00Added an answer on May 25, 2026 at 6:56 pm

    First, forget about the “1 for all other operations” and “exact power of 3” bits for a minute. What if the cost was just 2i when i is an exact power of 2?

    Well, suppose we pretend each operation costs four. That is, for each operation, we put four coins into our “IOU pile”… Then we use those coins to “pay” when we hit actual powers of 2. (This is one way of describing the potential function method.)

    Step 1: Deposit four coins. Need to pay 2*1 = 2, so our coin pile is at two.

    Step 2: Deposit four more coins. Need to pay 2*2 = 4, so our pile is again at two.

    Step 3: Deposit four coins. Pile now has six coins.

    Step 4: Deposit four coins. Pile now has ten coins, but 4 is a power of 2, so it’s time to pay 4*2 = 8, so our pile goes down to two coins again.

    Steps 5-7: Deposit four coins each. Total is now 14 coins.

    Step 8: Deposit four coins (total = 18), spend 8*2 = 16, once again two coins are left.

    It is pretty easy to prove that the steady state here is that we keep depleting our coins down to a constant (2), but we never go below. Therefore the amortized cost is four units per operation.

    Now, suppose operation X costs 2i when i is a power of 2 (and zero otherwise). Suppose operation Y costs 3i when i is a power of 3 (and zero otherwise). And suppose operation Z costs 1 except when i is a power of 2 or a power of 3. Observe that your problem is equivalent to performing operation X and Y and Z for every iteration… So if you can figure out the amortized cost of X, Y, and Z separately, you can just sum those to get the overall amortized cost.

    I just gave you X; I leave Y and Z as an exercise. (Although I do not believe the final answer is 10. Close to 10, perhaps…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to implement validation for a sequence of operations that all return Either[Error,Item]
I want to make a sequence of in-memory operations atomic. I presume there is
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Is there a shorthand version of this. I want to call one sequence and
First of all, I don't have multiplication, division operations so i could use shifting/adding,
I've got a sequence of bits, say 0110 [1011] 1111 Let's say I want
The exact sequence of ccnet operations(taken from here ): 1) Wait for the triggers
Given a sequence of operations: a*b*a*b*a*a*b*a*b is there a way to get the optimal
Say, I have a sequence of strings as an input and I want to
I was wondering if there was a Sequence Diagram generator for C#? Im using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.