/js-data-structures

Data structures in JS

Primary LanguageJavaScript

work in progress

Data structures

Types of Data structures

  • Stack
  • Queues:
    • FIFO
    • Priority queue
  • Linked lists:
    • singly | doubly linked
    • linear | circular
    • rolled | unrolled
    • unbalanced | self-balancing
  • Hash, Hashmap
  • Dictionary, Look-up table, Associative array
  • Trees:
    • Binary Search Tree
  • Graph
  • JS Data Structures:
    • Object
    • Array
    • Typed arrays
    • Map
    • WeakMap
    • Set
    • WeakSet

Time Complexity

Some classes of commonly encountered time complexity:

  • Constant Time: O(1)
    It only takes a single step for the algorithm to accomplish the task.

  • Logarithmic Time: O(log n) 
    The number of steps it takes to accomplish a task is decreased by some factor with each step.

  • Linear Time: O(n)
    The number of steps required is directly related (1 to 1).

  • Quadratic Time: O(n²) 
    The number of steps it takes to accomplish a task is n squared.

  • Exponential: O(C^n)
    The number of steps it takes to accomplish a task is a constant to the power of n.

  • Factorial: O(n!) 
    The number of steps it takes to accomplish a task is a n factorial.

Resources