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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:12:40+00:00 2026-05-30T07:12:40+00:00

It seems that the only Big-Oh behavior possible for adding something to a linked

  • 0

It seems that the only Big-Oh behavior possible for adding something to a linked list would be O(N) since you must traverse the entire list. However from what I hear the overall number of operations should be no more than N/2. Can someone please explain how this is possible, as I see it if you traverse from both ends of the linked list the overall behavior will still be O(N). What am I missing?

  • 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-30T07:12:41+00:00Added an answer on May 30, 2026 at 7:12 am

    If you are asking why will inserting an element at an arbitrary position in a doubly linked list of length N always take at most O(N/2), that could be because if you always maintain a separate pointer/reference to the middle element and a count of the total number of elements, you will only need to traverse at most half the list to insert at a given position.

    For example, say you have a list of [B, C, D, E, F, G, H], if you have a pointer to the E element and you know you have 7 items in your list. If you call insert(0, A) to insert element A at position 0, then you’ll know that if you traverse 3 links backwards you’ll go from position 3 to position 0 (remember zero index is the first, so you go from E@3 -> D@2 -> C@1 -> B@0). From there you can insert element A before your ‘current’ element (B).

    Note that people normally leave constant terms out of big-O analysis; O(n/2) and O(n) have the same performance characteristics as n increases.

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

Sidebar

Related Questions

I have just inherited a server application, however it seems that the only copy
I have a weird issue that only seems to be affecting IE 7. The
I've been investigating this issue that only seems to get worse the more I
it seems that on Rails or erb, the only way to output anything is
For Internet Explorer only it seems that the target (srcElement) of clicks, mousedowns, mouseups,
What I've read seems to indicate that the only way to do it is
I only read a little bit about this topic, but it seems that the
I have an application that seems to throw exceptions only after the program has
I tried things like $_ENV['CLIENTNAME'] == 'Console' but that seems to work on only
My problem is that I can only seem to click the button once, if

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.