Importance of Analysis of Algorithm

Algorithm analysis helps us determine the efficiency of the algorithm with respect to the time and space it uses.

Let’s understand it with an example

Suppose you want to transfer a file from Delhi to Mumbai. What would you choose, a flight or the Internet? (Given flight from Delhi to Mumbai takes 3 hours.)

You would think it would be a waste of time to use flight for a 2 MB file as we can send it easily to the destination within a minute using the Internet.

But what would happen if we need to send a file of 1 TB?

In that case, It would be much faster if we copy the file to a disk and fly it to the destination. Isn’t it?

From the above analysis, we can see that the time consumed by the Internet increased as the file size increased but we don’t need any extra storage.

But for flying the file from one destination to another the time is always constant but we have to use a storage device.

So we can conclude that the Internet way is good for files that are small and the flying way is efficient for large files.

Example Source: CrackingTheCodingInterview

Leave a Reply

Your email address will not be published. Required fields are marked *