This is the sixth post in the Algorithms and Data Structures Series and before a week I totally jumped to learning Data Structure and Algorithms without learning some fundamentals that are necessary to better understand and design algorithms and Data Structures.
I am talking about Algorithm Analysis, Frequency Count and Time Complexity etc. But I will only learn about Algorithm Analysis.
What is Algorithm Analysis?
Algorithm Analysis is a process of estimating the computational complexity of an algorithm. This is done by providing an arbitrarily large input to the algorithm to estimate its complexity function.
Analysis of Algorithms is an important part of Computer Science theory as it provides the theoretical estimation of resources like memory use etc to solve a given problem.
Usually there are two things that we look for when doing analysis of an algorithm, Time Complexity and Space Complexity.
Time Comlpexity
No matter how you perform an algorithm, in your head or on the computer it will always take some time to solve the problem that it was designed for. The estimation of how much time an algorithm will take with a given input during the analysis is called the Time Complexity.
To calculate the time complexity of an algorithm you simply add the machine instructions it will execute as a function of the size of the input.
Calculating the time complexity of an algorithm is something that I still don't understand but here the answer that someone gave on StackOverflow that I think simplifies the process of doing just that.
Space Complexity
The analysis of an algorithm to estimate the memory resources that will be used during the process is called Space Complexity.
The same goes for calculating the space complexity of an algorithm, you look for all the memory allocation and all the variables that algorithm will initialize during the process to calculate the space complexity of an algorithm.
Both time complexity and space complexity are function of the size of the input which mean math and I am not so good with math as I am right now so have to again postpone this for some other day.
Other Complexities
Nowadays there more things that are considered in designing an algortihm than just time and space. As the use of internet is growing day by day and the cloud computing is getting better and better, Data Transfer Complexity is also a thing that is considered in designing or choosing an algorithm.
You algorithm must be efficient is tranferring data from one computer to other on the internet for it to have a better Data Transfer.
And just like Data Transfer, power consumption is also considered when designing algorithms.