DEV Community

Cover image for Big O Basics
Danielle Richardson
Danielle Richardson

Posted on

3

Big O Basics

The code we choose to use can impact the speed and the performance of our program. How would we know which algorithm is most efficient? Big O Notation is used in Computer Science and measures how quickly the runtime of an algorithm based on the number of input in a function.

Big O looks at the worst case scenario or the max number of steps to take in a problem. On the other hand, Big Omega looks at the best case scenario or the least number of steps to take in a problem.

Common Runtimes from least to greatest effectiveness:

  • O(n^2): Quadratic time - as (n) grows, runtime squares.
  • O(n): Linear - as (n) scales, runtime scales.
  • O(log n): Logarithmic time - halves dataset until it finds (n).
  • O(1): Constant - as (n) grows, there is no impact.

Big O Complexity chart

Big ) Chart

This chart shows the runtime with green shaded area being the most effective to the red shaded areas being the least effective.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (1)

Collapse
 
thedanielleellis profile image
Danielle Richardson β€’

Thanks!

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay