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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:23:15+00:00 2026-05-25T06:23:15+00:00

I am trying to list time complexities of operations of common data structures like

  • 0

I am trying to list time complexities of operations of common data structures like Arrays, Binary Search Tree, Heap, Linked List, etc. and especially I am referring to Java. They are very common, but I guess some of us are not 100% confident about the exact answer. Any help, especially references, is greatly appreciated.

E.g. For singly linked list: Changing an internal element is O(1). How can you do it? You HAVE to search the element before changing it. Also, for the Vector, adding an internal element is given as O(n). But why can’t we do it in amortized constant time using the index? Please correct me if I am missing something.

I am posting my findings/guesses as the first answer.

  • 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-25T06:23:15+00:00Added an answer on May 25, 2026 at 6:23 am

    Arrays

    • Set, Check element at a particular index: O(1)
    • Searching: O(n) if array is unsorted and O(log n) if array is sorted and something like a binary search is used,
    • As pointed out by Aivean, there is no Delete operation available on Arrays. We can symbolically delete an element by setting it to some specific value, e.g. -1, 0, etc. depending on our requirements
    • Similarly, Insert for arrays is basically Set as mentioned in the beginning

    ArrayList:

    • Add: Amortized O(1)
    • Remove: O(n)
    • Contains: O(n)
    • Size: O(1)

    Linked List:

    • Inserting: O(1), if done at the head, O(n) if anywhere else since we have to reach that position by traversing the linkedlist linearly.
    • Deleting: O(1), if done at the head, O(n) if anywhere else since we have to reach that position by traversing the linkedlist linearly.
    • Searching: O(n)

    Doubly-Linked List:

    • Inserting: O(1), if done at the head or tail, O(n) if anywhere else since we have to reach that position by traversing the linkedlist linearly.
    • Deleting: O(1), if done at the head or tail, O(n) if anywhere else since we have to reach that position by traversing the linkedlist linearly.
    • Searching: O(n)

    Stack:

    • Push: O(1)
    • Pop: O(1)
    • Top: O(1)
    • Search (Something like lookup, as a special operation): O(n) (I guess so)

    Queue/Deque/Circular Queue:

    • Insert: O(1)
    • Remove: O(1)
    • Size: O(1)

    Binary Search Tree:

    • Insert, delete and search: Average case: O(log n), Worst Case: O(n)

    Red-Black Tree:

    • Insert, delete and search: Average case: O(log n), Worst Case: O(log n)

    Heap/PriorityQueue (min/max):

    • Find Min/Find Max: O(1)
    • Insert: O(log n)
    • Delete Min/Delete Max: O(log n)
    • Extract Min/Extract Max: O(log n)
    • Lookup, Delete (if at all provided): O(n), we will have to scan all the elements as they are not ordered like BST

    HashMap/Hashtable/HashSet:

    • Insert/Delete: O(1) amortized
    • Re-size/hash: O(n)
    • Contains: O(1)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to populate list boxes with data and at the same time
I'm trying to have a list of all the most common time zones for
I am trying to populate a select list with time. I want to create
I'm trying to list the latest destination (MAX departure time) for each train in
I'm trying to get a class memeber variable list at run time. I know
I am trying to reduce the time taken to send a list of DTO
I'm trying to convert an xml document to Python data structures. A sample of
I am trying out seeds.rb for the first time, and one of my data
I am trying to merge data between two identical schema databases using Linq-to-sql: List<Contact>
Im trying to list all categories in a VPP-folder using a module from Meridium

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.