: This means like running time when my code work is by Input and Operation time of it.
whenever we would like to show time complexity, we use Big-O notation
which is the algorithm that means it's effective and productive, whem input is lower.
🔎 More details on Time Complexity
We can make a list to distribute on each case to Three.
- Best Case
It's a fastest case when we're in putting a best input.- Worst Case
It's a lowest case in reverse compared than the Best case.- Average Case
Considering a bunch of case we can assume in advance. And get a total operating times and divide with it.
➡️ Most of case we're tryna use Worst case.
: this is a vital memorial Storage for running my code. it basically considered with Time-complexity together. We need to keep this in our mind, Space Complexity
is able to be different and depend on the circumstance where we run a code.
As a reasult, we have to think of them at the same time :)
: this is a way to be notated Operation time and how the complexity increases on our compiler by the size of Algorithm. We can also find out effective way for best situation of this code.
We can compare our lots of algorithm which one is gonna be effective by BCC(Big-O Complexity Chart)
.
This graph is gonna be made by Time complexity like down below.
this picture which looks like an equation means effectiveness will be reduced going to the right side.
🔎 More details on getting a Time complexity.
I'll just use Korean cuz idk how to say this sentences in English.
- 하나의 루프를 사용하여 단일 요소 집합을 반복하는 경우 : O(n)
- 컬렉션의 정반 이상을 반복하는 경우 : O(n/2) ➡️ O(n)
- 두 개의 다른 루프를 사용하여 두 개의 개별 콜렉션을 반복하는 경우 : O(n+m) ➡️ O(n)
- 두 개의 중첩 루프를 사용하여 단일 컬렉션을 반복하는 경우 : O(n²)
- 두 개의 중첩 루프를 사용하여 두 개의 다른 콜렉션을 반복하는 경우 : O(n * m) ➡️ O(n²)
- 컬렉션 정렬을 사용하는 경우 : O(n*log(n))
We can think of this easily. It's a result by used memorial Stoage of my Algorithm.
For example )
if we got an array which size is n, and also my algorithm makes an output,n*n
, the Space Complexity is gonna be n²
reference
1. Time-complexity
2. Time-complexity graph by Big-O