Engineer bro!
Tue Apr 12 2022 (3 months ago)
Engineer by mistake!
I am a software engineer by passion
The analysis of algorithms is the process of finding the computational complexity of algorithms—the amount of time, storage, or other resources needed to execute them. Usually, this involves determining a function that relates the size of an algorithm's input to the number of steps it takes (its time complexity) or the number of storage locations it uses (its space complexity).
The term "analysis of algorithms" was coined by Donald Knuth. Algorithm analysis is an important part of a broader computational complexity theory, which provides theoretical estimates for the resources needed by any algorithm which solves a given computational problem. These estimates provide an insight into reasonable directions of the search for efficient algorithms.
There could be many ways to solve a problem. But we can not use all of them at once, so we need to find the most efficient and appropriate solution. In order to find an efficient solution, we need to analyse all the solutions we have.
As you can see in the above figure, there could be three routes from city A to city D as follows.
A->B->D =
A->D =
A->C->D =
Here, A->B->D = is the shortest route to travel. In order to find the best routes among all possible routes, we have to analyse the cost of all routes. Then choose the route which has a lower cost.
Suppose we want to sort the names of all people in India in alphabetical order. The population of India is 138 Cr as of now and assume comparing two names will take (Constant time).
Total names = 138 Cr = 1380000000
Comparing names will take
Computer can execute instructions per second.
Consider we have only two sorting algorithms as of now.
Bubble Sort take amount of time(instructions) to execute, which means that it'll execute instructions in total. As our computer is able to execute only instructions per second, in order to execute instruction it'll take seconds.
Computer can execute instructions per second.
Total instructions that need to be executed is
Total amount of time needed to execute instructions on a computer that can execute instructions per second will be seconds.
Total minutes =
Total hours =
Total days =
Total years =
Can you believe, that even a computer needs ~31 years to sort all names of great India?
Merge Sort take amount of time(instructions) to execute, which means that it'll execute instructions in total. As our computer is able to execute only instructions per second, in order to execute instruction it'll take seconds.
You can see ~31 year problem can be solved in just 10 seconds by just choosing efficient algorithms.
We have to see what is the analysis of the algorithm and why analysis is important.
© 2021 dsabyte. All rights reserved
Comments (0)