# Time and Space Complexity

Day 2: 20|09|2023

Day 3: 21|09|2023

It is my day 2 today in revising DSA for the coding interview. Today I will delve into an analysis of algorithms. We will particularly talk about Time and Space Complexity. We have already discussed algorithms in our previous blog. If you haven't already please click the link to read.

Let us assume we have an algorithm A1. The algorithm A1 is an algorithm that searches for a particular user in an array called *usernames.* The array consists of information on the usernames of millions of users. Our algorithm will use Linear Search; which means it will check every element until it finds the user input username.

Assume the input user input is present at the last index in the array with a million indexes. Now we feed our search algorithm to two different computers with different specifications.

When we observe the time taken for the algorithm to execute it varies every single time on different computers. Therefore, it is very difficult to analyze algorithms in terms of the time it takes to execute.

It is when time complexity comes into the picture.

Time Complexity shows the relationship between how time grows as the input size grows.