Skip to content

collection of practice problems for simple Data Structures and Algorithms problems and problem solving patterns in JavaScript

Notifications You must be signed in to change notification settings

nditanaka/data-structures-algorithms-js

Repository files navigation

JavaScript DSA Practice Problems

Big O notation

There are three different notations:

  • big O - worst case. this is most important because in software engineering we typically plan for the worst case.
  • big Theta (Θ) - time complexity is the same for all n
  • big Omega (Ω) - best case

Big-O complexity chart The most common runtimes from fastest to slowest:

  1. constant O(1)
  2. logarithmic O(log N)
  3. linear O(N)
  4. log linear O(N log N)
  5. polynomial O(N^X) where X is some constant eg. quadratic O(N^2) and cubic O(N^3)
  6. exponential O(2^N)
  7. factorial O(N!)
Algorithm Time complexity (Best) Time complexity (Average) Time complexity (Worst) Space complexity
Bubble sort O(n) O(n^2) O(n^2) O(1)
Insertion sort O(n) O(n^2) O(n^2) O(1)
Selection sort O(n^2) O(n^2) O(n^2) O(1)
Merge sort O(nlogn) O(nlogn) O(nlogn) O(n)

Further reading

[1]https://www.bigocheatsheet.com
[2]https://bradfieldcs.com/algos/analysis/big-o-notation
[3]https://pythontutor.com/javascript.html#mode=display
[4]https://www.toptal.com/developers/sorting-algorithms
[5]https://visualgo.net/en

Instructions for using examples

To run these examples, just copy the code snippets and paste in Chrome Dev Tools under Snippets and run from there by pressing Cmd + Enter.

Call the function by it's name in the console:

Chrome DevTools Snippets view

About

collection of practice problems for simple Data Structures and Algorithms problems and problem solving patterns in JavaScript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published