Space and Time Complexity in Detail || Java + DSA Course || Blog 13
Every computer has a different processor, so algorithm can take different time to execute.
So, Time complexity doesn't talk about the time taken by the algorithm. Instead, it considers how many times each statement executes.
For a quick overview, we will be looking at:
- What is Time complexity?
- Solving Time complexity
- Big O Notation
- Big Omega Notation
- Theta Notation
- Little O Notation
- Little Omega Notation
- Space Complexity
What is Time Complexity?
Time Complexity tells us how the time is going to grow depending on its input so we can estimate value at any point.
This is the Graph of Different Time complexities:
Here, O(1) is constant time complexity. It means your time will remain constant at every input length.
O(log n) is the time complexity used by Binary search(algorithm used to search a value in a sorted array). It starts to curve at a certain point. The more the input, the less time Taken.
O(n) is the time complexity used by Linear search(algorithm used to search a value in a sorted array). As you can see, it is a straight line. The more input length, more is the time.
O(n^2) is the time complexity used by Selection sort(algorithm which sorts an element by picking minimum element every time and putting it in place). The time increases on a huge scale when the input increases.
So, we can say that the good one here, is O(1)(constant).
To categorize it through time, it is;
O(1) < O(log n) < O(n) < O(n^2)
Solving Time Complexity
Big O Notation(O)
Big Omega Notation(Ω)
Theta Notation(θ)
Little O Notation
Little Omega Notation
Space Complexity
This was all about Time and Space complexity which we will be using in Data Structures and algorithms.
__________________________________________________________________________________
Checkout:https://javaanddsa.blogspot.com/
Did you like our blog 13??
Comments
Post a Comment