GithubHelp home page GithubHelp logo

dsa's Introduction

Testing Datastructures

the purpose of this module is to test the data structures and the big O related to each of its methods

Big O Complexity (Best < Worst)

O(1) < O(log n) < O(n) < O(n log n) < O(n^2) < O(2^n) < O(n!)

Most common Collections

LISTS

List Append Prepend Insert Remove First Remove Last Remove Look by Value Look by index Data Structure
ArrayList O(1) O(n) O(n) O(n) O(1) O(n) O(n) O(1) Array
LinkedList O(1) O(1) O(n) O(1) O(n) O(n) O(n) O(n) Linked List

MAPS

Map Get Contains Remove Data Structure Advantage
HashMap O(1) O(1) O(1) Hash Table Permits null Key and Value
TreeMap O(log n) O(log n) O(log n) Red-black tree Natural Order + Permits null Value (only if key ordered)
LinkedHashMap O(1) O(1) O(1) Hash Table + Linked List Permits null Key and Value + Order

SETS

Set Add Remove Contains Next Data Structure Advantage
HashSet O(1) O(1) O(1) O(h/n) Hash Table Performance
TreeSet O(log n) O(log n) O(log n) O(log n) Red-black tree Natural Sort
LinkedHashSet O(1) O(1) O(1) O(1) Hash Table + Linked List Performance + Sort

QUEUES

Queue Offer Peek Poll Remove Data Structure Advantage
ArrayDeque O(1) O(1) O(1) O(n) Linked List Resizable
PriorityQueue O(log n) O(1) O(log n) O(n) Priority Heap Priority + Sorted

TREES - O(log n)

Tree Lookup Insert Remove Data Structure Advantage
Custom Binary Search Tree O(log n) O(log n) O(log n) - Faster than Lists to Lookup

Pros and Cons

Types Pros Cons Ref
HashTables Big O(1) and Secure Collision https://en.wikipedia.org/wiki/Hash_collision

dsa's People

Contributors

rodx64 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.