This content originally appeared on DEV Community and was authored by Hagar
What’s an algorithm?
Algorithm is simply a set of instructions implemented to perform a certain task. The word “algorithm” is derived from the name of Al-Khwarizmi and then was Latinized as “Algoritmi”.
Complexities:
Time and Space Complexities are so important and the gate to understand the whole concept of an algorithm. Furthermore, calculation of time and space complexity is so essential to reach the optimum solution to many problems.
Technically, complexity is used to measure performance of your algorithm and to know the best approach to solve the problem.
Time complexity: amount of time taken to process the set of instructions in terms of length of input.
Space Complexity: amount of space or memory taken by the set of instructions in terms of length of input.
Big O notation: is the upper bound of an algorithm, and is notated by O().
So, if we want to search for an element in an array, the worst case scenario is to find this element at last index in the array, which means traversing the whole array of length (N), having a time complexity of O(N) and space complexity of O(1) as we didn’t use any extra space.
Big ? notation: big omega is the lower bound of an algorithm, and is notated by ?().
Big ? notation: big theta is tight bound of an algorithm, and is notated by ?().
The most used notation is Big O notation, because it will give us an upper limit of the execution time i.e. the execution time in the worst case.
This content originally appeared on DEV Community and was authored by Hagar
Hagar | Sciencx (2021-04-19T15:57:26+00:00) Algorithms. Retrieved from https://www.scien.cx/2021/04/19/algorithms/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.