Greedy Algorithms

An algorithm is designed to find the best solution to a given problem. The greedy algorithm approach makes decisions based on the given solution domain. As a greedy person, the closest solution that appears to provide the best solution is chosen.

Greedy algorithms seek a locally optimised solution, which may eventually lead to globally optimised solutions. However, greedy algorithms do not always provide globally optimised solutions.

  • Counting Coins — The problem is to count to a desired value by selecting the fewest coins possible, and the greedy approach forces the algorithm to select the largest coin possible. If we are given coins numbered 1, 2, 5, and 10 and asked to count 18, the greedy procedure will be followed.

1 − Select one ₹ 10 coin, the remaining count is 8

2 − Then select one ₹ 5 coin, the remaining count is 3

3 − Then select one ₹ 2 coin, the remaining count is 1

4 − And finally, the selection of one ₹ 1 coins solves the problem

Though it appears to be working properly, we only need to select four coins for this count. However, if we slightly alter the problem, the same approach may not produce the same optimal result.

In a currency system with coins of 1, 7, and 10 values, counting coins for value 18 is absolutely optimal, but counting coins for value 15 may use more coins than necessary. The greedy approach, for example, will use 10 + 1 + 1 + 1 + 1, for a total of 6 coins. Alternatively, the same problem could be solved with only three coins (7 + 7 + 1). As a result, we can conclude that the greedy approach selects an immediately optimised solution and may fail where global optimization is important.

  • Divide and Conquer – The divide and conquer approach divides the problem at hand into smaller sub-problems, which are then solved independently. If we continue to divide the subproblems into smaller and smaller subproblems, we may eventually reach a point where no further division is possible. The smallest “atomic” sub-problems (fractions) are solved. The solutions to all sub-problems are finally merged to yield the solution to the original problem.
  • Divide – This step entails decomposing the problem into smaller sub-problems. Sub-problems should be a subset of the original problem. This step typically employs a recursive approach to divide the problem until no further sub-problems are divisible. Sub-problems become atomic in nature at this point, but they still represent some part of the overall problem.
  • Conquer – This step is given a large number of smaller sub-problems to solve. At this level, problems are generally considered solved on their own.
  • Merge/ Combine – When the smaller sub-problems are solved, this stage combines them recursively until they form a solution to the original problem. This algorithmic approach works recursively, and the conquer and merge steps are so close together that they appear to be one.
0

112 thoughts on “Greedy Algorithms”

  1. Thank you for another excellent article. Where else could anyone get that kind of info in such a perfect way of writing? I’ve a presentation next week, and I’m on the look for such info.

    0
  2. I found your weblog site on google and test a couple of of your early posts. Continue to maintain up the superb operate. I simply additional up your RSS feed to my MSN Information Reader. Seeking forward to reading more from you in a while!…

    0
  3. I’ve been browsing online more than three hours lately, but I by no means found any fascinating article like yours. It’s pretty worth sufficient for me. Personally, if all website owners and bloggers made just right content material as you probably did, the internet can be much more useful than ever before. “Baseball is 90 percent mental. The other half is physical.” by Lawrence Peter Berra.

    0
  4. Hello there! Do you know if they make any plugins to assist with Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Kudos!

    0
  5. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

    0
  6. Please let me know if you’re looking for a article author for your weblog. You have some really great posts and I believe I would be a good asset. If you ever want to take some of the load off, I’d really like to write some material for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Thank you!

    0
  7. Heya i am for the first time here. I came across this board and I in finding It truly useful & it helped me out much. I’m hoping to give something back and help others like you helped me.

    0
  8. I have been exploring for a little bit for any high-quality articles or blog posts on this sort of area . Exploring in Yahoo I at last stumbled upon this web site. Reading this information So i’m happy to convey that I’ve an incredibly good uncanny feeling I discovered exactly what I needed. I most certainly will make certain to don’t forget this site and give it a look regularly.

    0
  9. Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

    0
  10. Renew: An Overview. Renew is a dietary supplement formulated to aid in the weight loss process by enhancing the body’s regenerative functions

    0
  11. What¦s Happening i am new to this, I stumbled upon this I have found It positively useful and it has aided me out loads. I’m hoping to contribute & aid other users like its helped me. Great job.

    0
  12. Wow that was unusual. I just wrote an extremely long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say excellent blog!

    0
  13. It’s the best time to make some plans for the future and it’s time to be happy. I have read this post and if I could I desire to suggest you few interesting things or advice. Maybe you can write next articles referring to this article. I wish to read even more things about it!

    0
  14. Hi! Would you mind if I share your blog with my twitter group? There’s a lot of people that I think would really appreciate your content. Please let me know. Thanks

    0
  15. I am also writing to make you know of the incredible discovery my cousin’s girl encountered checking the blog. She picked up so many issues, not to mention what it’s like to have a very effective helping character to let other people clearly thoroughly grasp various multifaceted subject areas. You really exceeded my desires. Thanks for coming up with those warm and helpful, trusted, educational and as well as cool tips about your topic to Mary.

    0
  16. Hey! This is my first visit to your blog! We are a collection of volunteers and starting a new project in a community in the same niche. Your blog provided us beneficial information to work on. You have done a outstanding job!

    0
  17. What Is FitSpresso? The effective weight management formula FitSpresso is designed to inherently support weight loss. It is made using a synergistic blend of ingredients chosen especially for their metabolism-boosting and fat-burning features.

    0
  18. I would like to thank you for the efforts you’ve put in writing this web site. I’m hoping the same high-grade web site post from you in the upcoming as well. Actually your creative writing abilities has encouraged me to get my own website now. Actually the blogging is spreading its wings fast. Your write up is a good example of it.

    0
  19. Somebody necessarily lend a hand to make seriously posts I would state. This is the very first time I frequented your website page and up to now? I amazed with the research you made to make this actual publish amazing. Magnificent task!

    0
  20. I think this is among the most important info for me. And i’m glad reading your article. But wanna remark on some general things, The site style is ideal, the articles is really nice : D. Good job, cheers

    0
  21. Thanks for some other informative web site. The place else could I get that type of information written in such an ideal approach? I have a venture that I’m just now working on, and I have been at the glance out for such info.

    0
  22. Fantastic goods from you, man. I have understand your stuff previous to and you’re just extremely fantastic. I actually like what you’ve acquired here, certainly like what you are saying and the way in which you say it. You make it enjoyable and you still take care of to keep it wise. I can not wait to read much more from you. This is actually a wonderful website.

    0
  23. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several e-mails with the same comment. Is there any way you can remove me from that service? Thank you!

    0
  24. What i don’t realize is in fact how you’re now not actually a lot more smartly-appreciated than you may be now. You are very intelligent. You realize therefore significantly relating to this topic, produced me individually imagine it from so many various angles. Its like women and men aren’t involved until it is something to accomplish with Girl gaga! Your own stuffs outstanding. All the time deal with it up!

    0

Leave a Comment

Your email address will not be published. Required fields are marked *