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

  • Home
  • SEARCH
  • 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 6318569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:39:10+00:00 2026-05-24T15:39:10+00:00

Is it constant or O(n)? If O(n) are there similar data structures with constant

  • 0

Is it constant or O(n)? If O(n) are there similar data structures with constant time size operations?

  • 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-24T15:39:11+00:00Added an answer on May 24, 2026 at 3:39 pm

    Strangely, size and length have different descriptions in the ListBuffer docs. For sure, ListBuffer.length is constant time. Prior to Scala 2.8, length was indeed O(n), but this is now fixed. The implementation of size in TraversableOnce suggests that it is O(n), but I may be missing something.

    Other performance characteristics of Scala collections are documented here. For ListBuffer specifically,

                 head     tail     apply   update   prepend  append  insert
     ListBuffer  C        L        L       L        C        C       L
    

    where C is constant and L is linear time.

    Edit : Both ListBuffer length and size are now O(1) – The issue mentioned by @KiptonBarros was closed with Scala 2.9.1 see: https://issues.scala-lang.org/browse/SI-4933

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

Sidebar

Related Questions

People have asked similar questions about the efficiency of various data structures but none
Is there any way to use a constant as a hash key? For example:
Is there a variable or a preprocessor constant that allows to know that the
Is there a way to make a TSQL variable constant?
Is there a way to insert a string in a string constant/variable that contains
Is there a way to initialize all elements of an array to a constant
In ruby, is there a way to undefine a variable or constant once it's
By looking at our DB's error log, we found that there was a constant
I am looking for a data structure in Python that is similar to a
Can someone here tell me if there is something similar to LD_PRELOAD on recent

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.