본문 바로가기

Programming/Algorithm

그리디 알고리즘

반응형

탐욕 알고리즘은 말그대로 눈앞의 최적의 상황만을 쫓아 최종적인 해답에 도달하는 방법이다.

 

탐욕알고리즘은 여러 경우 중 하나를 결정해야 할 때마다 그 순간에 최적이라고 생각되는 것을 선택해 나가는 방식으로 진행하여 최종적인 답에 도달한다.

 

 

탐욕 알고리즘 문제를 해결하는 법

1. 선택절차(Selection procedure) : 현재 상태에서의 최적의 해답을 선택한다.

2. 적절성 검사(Feasibility check) : 선택된 해가 문제의 조건을 만족하는지 검사한다.

3. 해답 검사(Solution Check) : 원래의 문제가 해결되었는지 검사하고, 해결되지 않았다면 선택 절차로 돌아가 위의 과정을 반복한다.

 

 

 

Greedy Algorithm

an algorithmic paradigm that follows the problem solving approach of making the locally choice at each stage with the hope of finding a global optimum

 

Pros - simple, easy to implement run fast

cons - very often they dont' provide a globally optimum solution.

 

Even if we want to select the largest number in global, because greedy algorithm follows locally biggest number 7 and 11, not getting 20.

 

반응형