For many problems, making greedy choices leads to an optimal solution. These algorithms are applicable to optimization problems.
In a greedy algorithm, in each step, we will make a locally optimum solution such that it will lead to a globally optimal solution. Once a choice is made, we cannot retract it in later stages.
Proving the correctness of a greedy algorithm is very important, since not all greedy algorithms lead to globally optimum solution.
For ex- consider the problem where you are given coins of certain denomination and asked to construct certain amount of money in inimum number of coins.
Let the coins be of 1, 5, 10, 20 cents
If we want change for 36 cents, we select the largest possible coin first (greedy choice).
According to this process, we select the coins as follows-
20
20 + 10
20 + 10 + 5
20 + 10 + 5 + 1 = 36.
For coins of given denomination, the greedy algorithm always works.
But in general this is not true.
Consider the denomination as 1, 3, 4 cents
To make 6 cents, according to greedy algorithm the selected coins are 4 + 1 + 1
But, the minimum coins needed are only 2 (3 + 3)
Hence, greedy algorithm is not the correct approach to solve the 'change making' problem.
Infact, we can use dynamic programming to arrive at optimal solution to this problem.
Read more at http://gonitsora.com/algorithm-types-and-classification/#TdZOUE8KelEImvTA.99
สำหรับปัญหาต่างๆ มากมาย ทำให้ตัวเลือกโลภนำไปสู่โซลูชั่นที่เหมาะสมที่สุด ขั้นตอนวิธีการเหล่านี้จะสามารถใช้ได้กับปัญหาการเพิ่มประสิทธิภาพในขั้นตอนวิธีการโลภ ในแต่ละขั้นตอน เราจะทำในโซลูชั่นที่เหมาะสมเช่นว่านั้นจะนำไปสู่การแก้ปัญหาที่ดีที่สุดทั่วโลก ถ้าเลือกได้ เราไม่สามารถถอยได้ ในขั้นตอนต่อมาพิสูจน์ความถูกต้องของขั้นตอนวิธีการโลภ สำคัญมาก เพราะไม่ใช่ทุกขั้นตอนวิธีเชิงละโมบนำไปสู่ทั่วโลกสูงสุด โซลูชั่นสำหรับ EX - พิจารณาปัญหาที่คุณจะได้รับเหรียญของบางนิกาย และขอให้สร้างจำนวนหนึ่งของเงินจำนวน inimum ของเหรียญให้เหรียญเป็น 1 , 5 , 10 , 20 เซนต์ถ้าเราต้องการเปลี่ยน 36 เซนต์ เราเลือกเหรียญที่สุดก่อน ( เลือกโลภ )ตามกระบวนการนี้ เราเลือกดังนี้ - เหรียญ2020 + 1020 + 10 + 520 + 10 + 5 + 1 = 36สำหรับเหรียญระบุนิกาย อัลกอริทึมละโมบผลเสมอแต่โดยทั่วไป นี้ไม่เป็นความจริงพิจารณานิกายเป็น 1 , 3 , 4 เซนต์เพื่อให้ 6 เซนต์ , ตามขั้นตอนวิธีแบบละโมบเลือกเหรียญ 4 + 1 + 1แต่ อย่างน้อยต้องมี 2 เหรียญ ( 3 + 1 )ดังนั้นขั้นตอนวิธีแบบละโมบ ไม่ใช่แนวทางที่ถูกต้องเพื่อแก้ไขเปลี่ยนให้ " ปัญหาที่จริง เราสามารถใช้โปรแกรมพลวัตถึงโซลูชั่นที่เหมาะสมกับปัญหานี้อ่านเพิ่มเติมที่ http : / / gonitsora . com / ขั้นตอนวิธีการจำแนกชนิดและ / # tdzoue8keleimvta.99
การแปล กรุณารอสักครู่..
