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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:10:48+00:00 2026-05-11T17:10:48+00:00

Accordingly to the Wikipedia article on dynamic arrays , inserting/deleting at the end of

  • 0

Accordingly to the Wikipedia article on dynamic arrays, inserting/deleting at the end of the array is O(1) while inserting/deleting from the middle is O(n). Why exactly is that?

Also – if I have a dynamic array with 5 elements and I insert a new element at position 6 the operation is O(n) whereas if I use the function to append to the end of the array it is O(1). Isn’t this the same operation assuming the array doesn’t need to resize in either case? Or does appending to the dynamic array really insert the new element somewhere besides position 6?

Thanks!

EDIT: I think my main confusion is the difference between inserting at the end of the array and inserting at a specific position that is equivalent to the end of the array.

I suppose a pointer to the memory address of the end of the array is kept handy and that is why the append operation is quick. Conversely, if I specify a precise position (even if it is the end of the array) it won’t know that inserting at that position is tantamount to using the aforementioned memory address so it has to traverse the entire array, eh?

  • 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-11T17:10:48+00:00Added an answer on May 11, 2026 at 5:10 pm

    The order of magnitude would depend entirely on what sort of data structure the “dynamic array” actually is (“dynamic array” isn’t a strictly defined data structure, it’s more of a desired result achieved by employing a particular data structure). The example that you give would be that reflect by a dynamic array achieved by employing a linked list. Adding to the end could be O(1) if the list structure kept a pointer to the final element. Inserting (regardless of the index) would require traversing the linked list, meaning one operation per node up until the desired index.

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

Sidebar

Related Questions

According to the Wikipedia article on linked lists , inserting in the middle of
I realise if I remove subviews accordingly from my application, the memory management seems
I've been here and accordingly found out that this piece of code here var
Problem: To get the index values of an array to print accordingly in value
According to Wikipedia NoSQL article , there are a lot of NoSQL implementations. What's
I read an article on virtual table in Wikipedia . class B1 { public:
I'm wondering just how pervasive JavaScript is. This article states that 73% of websites
According to the Wikipedia article on suffix trees , suffix trees can be used
According to this Wikipedia article on Google App Engine : Developers have read-only access
According to this Wikipedia article , you are allowed 3,000 files per app but

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.