When and Why should we calculate Big-O?

exploreIT
3 min readDec 11, 2021

Yeah! That’s an interesting question. If you are a programmer, you must have a clear understanding about this notation.

Wait! A short NOTE: Once you read this article completely and understand this concept properly, I’ll recommend you to visit this or any other site for knowing about other different types of Asymptotic Notations.

Okay, let’s try to answer your question. But before that let me ask you- Do you know what Big-O actually is?

Don’t worry if you don’t, I’m going to provide a very simple definition here.

Big-O: In computer science, Big-O represents the efficiency or performance of an algorithm. Big-O makes it easy to compare algorithm speeds and gives you a general idea of how long it will take the algorithm to run.

Not clear?

Well, what would be your answer if I ask- What is a good code?

If you don’t know- there are 2 main things by which you can judge whether a code is good or not, and these are — Readability and Scalability. (If you want to know these two in depth, please Visit!)

Scalability is something where comes the Big-O. When we talk about Big-O and scalability of code, we simply mean when we grow bigger and bigger with our input, how much does the algorithm or function slows down. The less it slows down or the slower it slows down, the better it is. keep this in mind, Big-O doesn’t measure things in seconds. Instead, it focuses on how quickly the runtime grows.

So, is this the reason why we calculate Big-O?

Yes! We want to measure the efficiency of our code in terms of Time and Space Complexity as these are some of the resources that have a very big importance in our lives.

NOTE: In Big-O, we are always worried about the worst case that our code can have. And yes, when inputs are small the Big-O notation doesn’t matter that much. Scalable code means thinking outside of just the small, so that when things grow, we don’t have to fix things again and again.

Now, if you ask- When should we calculate Big-O?

Off course, when you want to measure your code’s efficiency. It may be because of you have more than one working solution and you want to choose the efficient one, or there might be some other reason as well, but these are the very basic idea about why we calculate Big-O.

Hey, did you like the explanation?

If yes then don’t forget to follow exploreIT as I regularly come up with interesting topics related to programming. And of course, if you have any difficulty understanding the concepts or find anything wrong in the article please feel free to comment below!

Feet free to connect — https://www.linkedin.com/in/salman-shaikh-82989b1b9/

See you in the next article, Bye Bye!

Related Article(s)

--

--

exploreIT

This is Salman, a Software Developer. Here in exploreIT, I come up with interesting concepts related to programming that you may like. Do check & have fun:)