
그리디 알고리즘
0. 들어가며 매 단계에서 ‘가장 좋아 보이는’ 해답을 선택하는 알고리즘 지역적인 최적의 해결 방법 → 전역적인 최적의 해결 방법 1. 기본적인 그리디 알고리즘 1) 최단 작업 우선 스케줄링 평균 대기 시간을 줄이기 위해 일 처리가 가장 빠른 사람을 맨 앞으로 가장 빠른 사람을 선택→그리디 알고리즘 2) 연습 문제 24: 최단 작업 우선 스케줄링 #include #include #include #include template auto compute_waiting_times(std::vector& service_times) { std::vector W(service_times.size()); W[0] = 0; for(auto i=1; i
- Data Structure & Algorithm
- · 2023. 7. 2.