Member-only story

The Complete Guide To Understanding Time and Space Complexity of Algorithms

This topic is super trendy in interviews, so you should know it if you are looking for a job

Juan Cruz Martinez
Better Programming
15 min readApr 29, 2021

--

Graphic with a person pointing to question marks, a flowchart, an hourglass, and the words “time and space complexity”
Image by the author

There’s more than one way to solve a problem, but not all of them are the best. Not every solution is capable of efficiently using our resources. Therefore we need to find the best, most efficient solution to a problem before taking action.

In programming, we can’t leave the mechanism of finding the best solution, the best algorithm, to guesswork. We need a clear standard to evaluate the efficiency of solutions. This is where the concepts of time and space complexity step in. They help us determine the algorithm’s efficiency based on the required resources.

In this article, we are going to talk about the concepts of time and space complexity and how we can use them to select the most efficient algorithm for a given task. And of course, this is where notations like O(n) and O(logn), which may have baffled you while learning algorithms, come from.

Efficiency of Algorithms

We measure an algorithm’s efficiency using the time and space (memory) it takes for execution. Time is important because we need our programs to run as fast as possible to deliver…

--

--

Juan Cruz Martinez
Juan Cruz Martinez

Written by Juan Cruz Martinez

I stream, blog, and make youtube videos about tech stuff. I love coding, I love React, and I love building stuff!

No responses yet

What are your thoughts?