As programmers, we often find ourselves asking the same two questions over and over again:

  1. How much time does this algorithm need to complete?
  2. How much space does this algorithm need for computing?

To put it in other words, in computer programming, there are often multiple ways to solve a problem, so

  1. How do we know which solution is the right one?
  2. How do we compare one algorithm against another?

The big picture is that we are trying to compare how quickly the runtime of algorithms grows with respect to the size of their input. We think of the runtime of an algorithm as a function of the size of the input, where the output is how much work is required to run the algorithm.

To answer those questions, we come up with a concept called Big O notation.

  • Big O describes how the time is taken, or memory is used, by a program scales with the amount of data it has to work on
  • Big O notation gives us an upper bound of the complexity in the worst case, helping us to quantify performance as the input size becomes arbitrarily large
  • In short, Big O notation helps us to measure the scalability of our code

Time and Space Complexity

When talking about Big O Notation it’s important that we understand the concepts of time and space complexity, mainly because_ Big O Notation_ is a way to indicate complexities.

Complexity is an approximate measurement of how efficient (or how fast) an algorithm is and it’s associated with every algorithm we develop. This is something all developers have to be aware of. There are 2 kinds of complexities: time complexity and space complexity. Time and space complexities are approximations of how much time and space an algorithm will take to process certain inputs respectively.

Typically, there are three tiers to solve for (best case scenario, average-case scenario, and worst-case scenario) which are known as asymptotic notations. These notations allow us to answer questions such as: Does the algorithm suddenly become incredibly slow when the input size grows? Does it mostly maintain its fast run time performance as the input size increases?

#performance #development #big o complexity #big o notation #big data

What Is Big O Notation?
1.25 GEEK