-
Notifications
You must be signed in to change notification settings - Fork 6
Big O
Big-O 표기법(Big-O Notation)은 알고리즘의 시간복잡도를 표현하는 방법으로 입력 크기
Big-O 표기법은 알고리즘의 정확한 실행 시간을 계산하는 것이 아니라 입력 크기가 커질수록 연산량이 얼마나 빠르게 증가하는지를 표현합니다.
시간복잡도는 일반적으로 다음과 같은 순서로 증가합니다.
왼쪽에 가까울수록 효율적인 알고리즘이며 오른쪽으로 갈수록 연산량이 빠르게 증가합니다.
Big-O 표기법은 다음과 같은 규칙을 따릅니다.
상수 배수는 알고리즘의 성장률에 큰 영향을 주지 않기 때문에 제거합니다.
입력 크기
상수 계수는 제거하고 성장률만 표현합니다.
for(int i = 0; i < n; i++){
System.out.println(i);
}
for(int i = 0; i < n; i++){
System.out.println(i);
}for i in range(n):
print(i)
for i in range(n):
print(i)for(let i = 0; i < n; i++){
console.log(i);
}
for(let i = 0; i < n; i++){
console.log(i);
}시간복잡도는
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
System.out.println(i + " " + j);
}
}
for(int i = 0; i < n; i++){
System.out.println(i);
}for i in range(n):
for j in range(n):
print(i, j)
for i in range(n):
print(i)for(let i = 0; i < n; i++){
for(let j = 0; j < n; j++){
console.log(i, j);
}
}
for(let i = 0; i < n; i++){
console.log(i);
}이 경우 첫 번째 반복문은
Input Size & Algorithm Complexity
5주차 - Two Pointers / Sliding Window
13주차 - Simulation / Implementation
백현빈 → 강민주 → 조수빈 → 임현빈 → 전병훈 → 이건희
(이후 동일한 순서로 반복)