shlogg · Early preview
Hanzla Baig @mirzahanzla01

Visualizing Big-O Time Complexity With Flowcharts In JavaScript

Big-O complexity in JavaScript explained with flowcharts. Logarithmic time (O log(n)) loops through conditions, linear time (O(n)) loops through all integers, and quadratic time (O(n^2)) has multiple loops with growing exponent.

I highly recommend Edison's post on Big-O complexity in JavaScript. It's the friendliest article I've seen on the topic.

  
  
  Article No Longer Available

I'll be taking points from Edison here as I visualize Big-O time complexity with flowcharts.

  
  
  O log(n)

Logarithmic Time

The way I visually understand time complexity is by looking at the iterator, i*2 for example , and looking at how many loops the function has.

  
  
  O(n)

Linear Time
Linear time and logarithmic time look similar but the output is different because of the conditions of the loop. exampleLogarithmic(100) will...