Data Structure Time Complexity Cheat Sheet



Java Collections Complexity cheatsheet

Big-O Algorithm Complexity Cheat Sheet BigĀ­O Complexity Chart This interactive chart, created by our friends over at MeteorCharts, shows the number of operations (y axis) required to obtain a result as the number of elements (x axis) increase. C Data Structures and Algorithms Cheat Sheet. Table of Contents. Time Complexity. Time Complexity. O(1) Insert Index. O(n) Insert Tail. Data Structure Time Complexity Space Complexity Average Worst Worst. Big-O Algorithm Complexity Cheat Sheet Created Date: 8/24/2016 10:43:56 AM.

Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
Set | Add | Remove | Contains | Next | Size | Data Structure
----------------------|----------|----------|----------|----------|------|-------------------------
HashSet | O(1) | O(1) | O(1) | O(h/n) | O(1) | Hash Table
LinkedHashSet | O(1) | O(1) | O(1) | O(1) | O(1) | Hash Table + Linked List
EnumSet | O(1) | O(1) | O(1) | O(1) | O(1) | Bit Vector
TreeSet | O(log n) | O(log n) | O(log n) | O(log n) | O(1) | Red-black tree
CopyOnWriteArraySet | O(n) | O(n) | O(n) | O(1) | O(1) | Array
ConcurrentSkipListSet | O(log n) | O(log n) | O(log n) | O(1) | O(n) | Skip List
Queue | Offer | Peak | Poll | Remove | Size | Data Structure
------------------------|----------|------|----------|--------|------|---------------
PriorityQueue | O(log n) | O(1) | O(log n) | O(n) | O(1) | Priority Heap
LinkedList | O(1) | O(1) | O(1) | O(1) | O(1) | Array
ArrayDequeue | O(1) | O(1) | O(1) | O(n) | O(1) | Linked List
ConcurrentLinkedQueue | O(1) | O(1) | O(1) | O(n) | O(n) | Linked List
ArrayBlockingQueue | O(1) | O(1) | O(1) | O(n) | O(1) | Array
PriorirityBlockingQueue | O(log n) | O(1) | O(log n) | O(n) | O(1) | Priority Heap
SynchronousQueue | O(1) | O(1) | O(1) | O(n) | O(1) | None!
DelayQueue | O(log n) | O(1) | O(log n) | O(n) | O(1) | Priority Heap
LinkedBlockingQueue | O(1) | O(1) | O(1) | O(n) | O(1) | Linked List
Map | Get | ContainsKey | Next | Data Structure
----------------------|----------|-------------|----------|-------------------------
HashMap | O(1) | O(1) | O(h / n) | Hash Table
LinkedHashMap | O(1) | O(1) | O(1) | Hash Table + Linked List
IdentityHashMap | O(1) | O(1) | O(h / n) | Array
WeakHashMap | O(1) | O(1) | O(h / n) | Hash Table
EnumMap | O(1) | O(1) | O(1) | Array
TreeMap | O(log n) | O(log n) | O(log n) | Red-black tree
ConcurrentHashMap | O(1) | O(1) | O(h / n) | Hash Tables
ConcurrentSkipListMap | O(log n) | O(log n) | O(1) | Skip List

commented Feb 7, 2021

You've mixed data structures between LinkedList and ArrayDequeue in the Queue section. Openshot older versions.

commented Mar 11, 2021

Do these figures still hold in the new Java versions? If not, then I would suggest adding the Java-version these performances were measured at.

I presume by and large the performance does not change dramatically though.

commented Apr 21, 2021

Do these figures still hold in the new Java versions? If not, then I would suggest adding the Java-version these performances were measured at.

I presume by and large the performance does not change dramatically though.

I highly doubt this was measured. It's probably inferred from the implementation. And I doubt the complexity of the implementations changed. Most algorithms have been around for a long time.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Policies

Participation

Data Structure Time Complexity Cheat Sheet

Students are expected to attend and contribute regularly in class. This means answering questions in class, participating in discussions, and helping other students.

Foreseeable absences should be discussed with the instructor ahead of time.

Classroom Recording

Notre Dame has implemented an Echo360 classroom recording system. This system allows us to record and distribute lectures to you in a secure environment. You can watch these recordings on your computer, tablet, or smartphone. The recordings can be accessed within Sakai. Look for the tool labeled 'Echo360 ALP' on the left hand side of the course.

Because we will be recording in the classroom and/or using an active learning environment, your questions and comments may be recorded. (Video recordings typically only capture the front of the classroom.) If you have any concerns about your voice or image being recorded, please speak to me to determine an alternative means of participating. No content will be shared with individuals outside of your course without your permission except for faculty and staff that need access for support or specific academic purposes.

Bartender

These recordings are jointly copyrighted by the University of Notre Dame and your instructor. Posting them to other websites, including YouTube, Facebook, Vimeo, or elsewhere without express, written permission may result in disciplinary action and possible civil prosecution.

Late Work

Data Structure Time Complexity Cheat Sheet

Algorithm Complexity Cheat Sheet

In the case of a serious illness or other excused absence, as defined by university policies, coursework submissions will be accepted late by the same number of days as the excused absence.

Otherwise, there is a penalty of 25% per day late (except where noted). You may submit some parts of an assignment on time and some parts late. Seagate backup drives for mac. Each submission must clearly state which parts it contains; no part can be submitted more than once.

Honor Code

All work that you submit must be your own. Collaboration is encouraged but must be disclosed by all parties. Print or online resources are allowed, but must be disclosed. However, you may not look at solutions from other current or past students, or any other source.

Students with Disabilities

Any student who has a documented disability and is registered with Disability Services should speak with the professor as soon as possible regarding accommodations. Students who are not registered should contact the Office of Disability Services.