Algorithms
Hagar
Posted on April 19, 2021
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.
Posted on April 19, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.