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 9115579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:27:59+00:00 2026-06-17T04:27:59+00:00

http://en.wikipedia.org/wiki/Dynamic_array#Performance What exactly does it mean? I thought inserting at the end would be

  • 0

http://en.wikipedia.org/wiki/Dynamic_array#Performance

What exactly does it mean?

I thought inserting at the end would be O(n), as you’d have to allocate say, twice the space of the original array, and then move all the items to that location and finally insert the item. How is this O(1)?

  • 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-06-17T04:28:00+00:00Added an answer on June 17, 2026 at 4:28 am

    Amortized O(1) efficiency means that the sum of the runtimes of n insertions will be O(n), even if any individual operation may take a lot longer.

    You are absolutely correct that appending an element can take O(n) time because of the work required to copy everything over. However, because the array is doubled each time it is expanded, expensive doubling steps happen exponentially less and less frequently. As a result, the total work done in n inserts comes out to be O(n) rather than O(n2).

    To elaborate: suppose you want to insert a total of n elements. The total amount of work done copying elements when resizing the vector will be at most

    1 + 2 + 4 + 8 + … + n ≤ 2n – 1

    This is because first you copy one element, then twice that, then twice that, etc., and in the absolute worst case copy over all n elements. The sum of this geometric series works out to 2n – 1, so at most O(n) elements get moved across all copy steps. Since you do n inserts and only O(n) total work copying across all of them, the amortized efficiency is O(1) per operation. This doesn’t say each operation takes O(1) time, but that n operations takes O(n) time total.

    For a graphical intuition behind this, as well as a rationale for doubling the array versus just increasing it by a small amount, you might want to check out these lecture slides. The pictures toward the end might be very relevant.

    Hope this helps!

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

Sidebar

Related Questions

I'm using PeerTracker http://en.wikipedia.org/wiki/PeerTracker to track torrent hashes. I have a simple HTML page
I have read the explanation in http://en.wikipedia.org/wiki/PageRank and i understand that the page rank
I have the following JSON string (from wikipedia http://en.wikipedia.org/wiki/JSON ) { name:Product, properties: {
I have used an example from http://en.wikipedia.org/wiki/Template_metaprogramming const unsigned long long y = Factorial<0>::value;
I have a wikipedia url say(of some language but not english), http://ru.wikipedia.org/wiki/Liz_Claiborne,_Inc I want
http://en.wikipedia.org/wiki/Rotation_matrix Suppose i have (x,y) 2D pixels for image, now i want to rotate
http://pt.wikipedia.org/wiki/Merge_sort#Java That code does not compile. Thank you.
// Refer: http://en.wikipedia.org/wiki/Decimal I have a snippet like this in my java source code,
http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch I've worked with several projects and all have they used a database centric
http://en.wikipedia.org/wiki/Lamport%27s_bakery_algorithm I have some problems to understand this algorithm. What happens if the current

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.