Algorithmic Efficiency
도입됨
9:10
알고리즘 및 프로그래밍
백만 명의 이름이 있는 전화번호부를 상상해 보십시오. 하나를 찾아야 합니다. 하나씩 확인하면 하루 종일 걸릴 수도 있습니다. 약…안에 찾을 수 있는 방법이 있습니다.
영어 내레이션 · 영어와 중국어 자막 전환 가능
이 수업의 내용
| English | 의미 |
|---|---|
| Algorithmic efficiency/ˌælɡəˈrɪθmɪk ɪˈfɪʃənsi/ | 알고리즘 효율성 |
| slow/sləʊ/ | 느린 |
| steps/steps/ | 단계 |
| reasonable/ˈriːzənəbl/ | 합리적인 |
| unreasonable/ʌnˈriːzənəbl/ | 부당함 |
| heuristic/hjuːˈrɪstɪk/ | 히어리스틱 방법 |
정확함만으로 충분하지 않을 수도 있음
- 두 알고리즘이 모두 정확할 수 있으나, 그중 하나는 사용하기 훨씬 더 낳을 수 있습니다.
- 알고리즘 효율성(algorithmic efficiency) 은 주로 시간과 메모리와 같은 자원을 소모하는 정도에 따라 알고리즘을 비교합니다.
- 정확하지만 느린 알고리즘은 큰 입력 데이터에서는 쓸모가 없을 수 있습니다.
- 따라서 확장성을 비교하는 방법이 필요합니다.
Algorithmic efficiency compares algorithms by:
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Efficiency is about time and memory as input grows.
n이 커질수록 단계 수 세기
- 입력 크기 $n$가 커질 때 알고리즘이 소모하는 단계(steps) 의 개수를 추정하십시오.
- 선형 탐색(linear search)은 약 $n$개의 단계를 요구하고, 이진 탐색(binary search)은 약 $\log_2 n$개, 모든 쌍을 비교하는算法은 약 $n^2$개를 요합니다.
- $n$가 커지면 이러한 차이점은 극적으로 커집니다.
- 성장의 모양이 스톱워치를 훨씬 더 중요하게 만듭니다.

알고리즘의 실행 시간이 입력 크기 n에 따라 어떻게 증가하는지

How running time grows with n
Slide n and compare the curves: log n stays almost flat, n rises steadily, n² explodes. This is why we compare algorithms by how they scale, not with a stopwatch.
Match each algorithm to its rough number of steps for input size n.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
These growth rates decide which algorithm scales.
Which growth is considered unreasonable as n gets large?
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Exponential growth quickly becomes far too slow.
When an exact answer is too slow, a ______ finds a good-enough solution fast.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
A heuristic trades a perfect answer for speed.
합리적인 vs 비합리적인
- 합리적인 실행 시간과 비합리적인 실행 시간을 구분합니다.
- 대략적으로 $n$ 또는 $n^2$와 같은 성장 속도는 합리적이지만, 추가 요소마다 처리 단계를 두 배로 늘리는 것($2^n$)은 비합리적입니다.
- 정확한 답을 구하는 데 시간이 너무 많이 걸릴 경우 히어리스틱을 사용하세요. 이는 빠르게 도출된 충분히 좋은 해결책입니다.
- 완벽하지는 않으나, 시간 내에 완벽한 해법을 찾을 수 없는 상황에서 유용합니다.
A binary search of 1,000,000 sorted items needs at most about how many steps? (2^20 ≈ a million)
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Because 2^20 is just over a million, ~20 halvings suffice.
If an algorithm is correct, it will always run fast enough on large inputs.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
False. A correct algorithm can still be too slow on large inputs; it must also finish in a reasonable time.
이 카드는 내용이 수정되어 번역이 업데이트될 때까지 영어로 표시됩니다.
Too slow to use
- This is why some correct algorithms are too slow 缓慢 to run in practice on large inputs.
- Being correct is not enough — an algorithm must also finish in a reasonable time.
A million items. A linear search of 1,000,000 sorted items may take up to 1,000,000 steps. A binary search takes at most about 20, because $2^{20}$ is just over a million. On small lists the gap barely matters; on a million sorted items, binary search can greatly reduce the number of comparisons.
Algorithmic efficiency compares algorithms by resources as input size $n$ grows: linear $n$, binary $\log_2 n$, all-pairs $n^2$. Growth like $n$ or $n^2$ is reasonable; $2^n$ is unreasonable (use a heuristic). A correct algorithm that is too slow on large inputs is not good enough.
어떤 문제가 있었나요? 사이트 팀만 이 내용을 볼 수 있습니다.