Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A set of flowers have been planted in a line, with each flower represented by it

ID: 3818053 • Letter: A

Question

A set of flowers have been planted in a line, with each flower represented by its distance (in nonnegative integer units) from the left end of the row of flowers. We need to install sprinklers to keep the flowers watered, but wo would like to minimize the number of sprinklers that we use. Each sprinkler has the same radius r, representing how many units from the position of the sprinkler (in either direction) a flower can be in order to still be watered by the sprinkler. Design and write a greedy algorithm that, given the sprinkler radius r and the positions p_i of each flower i, will find where the sprinklers should be placed in order to cover all the flowers with a minimum number of sprinklers. Prove that your algorithm always finds an optimum result.

Explanation / Answer

Voracious is an algorithmic worldview that develops an answer piece by piece, continually picking the following piece that offers the most evident and quick advantage. Covetous calculations are utilized for improvement issues. An enhancement issue can be tackled utilizing Greedy if the issue has the accompanying property: At each progression, we can settle on a decision that takes a gander right now, and we get the ideal arrangement of the total issue.
On the off chance that a Greedy Algorithm can take care of an issue, then it for the most part turns into the best strategy to take care of that issue as the Greedy calculations are by and large more productive than different methods like Dynamic Programming. Be that as it may, Greedy calculations can't generally be connected. For instance, Fractional Knapsack issue (See this) can be illuminated utilizing Greedy, yet 0-1 Knapsack can't be tackled utilizing Greedy.
Taking after are some standard calculations that are Greedy calculations.
1) Kruskal's Minimum Spanning Tree (MST): In Kruskal's calculation, we make a MST by picking edges one by one. The Greedy Choice is to pick the littlest weight edge that doesn't bring about a cycle in the MST developed up until this point.
2) Prim's Minimum Spanning Tree: In Prim's calculation likewise, we make a MST by picking edges one by one. We keep up two sets: set of the vertices effectively incorporated into MST and the arrangement of the vertices not yet included. The Greedy Choice is to pick the littlest weight edge that interfaces the two sets.
3) Dijkstra's Shortest Path: The Dijkstra's calculation is fundamentally the same as Prim's calculation. The most brief way tree is developed, edge by edge. We keep up two sets: set of the vertices officially incorporated into the tree and the arrangement of the vertices not yet included. The Greedy Choice is to pick the edge that interfaces the two sets and is on the littlest weight way from source to the set that contains not yet included vertices.
4) Huffman Coding: Huffman Coding is a misfortune less pressure system. It doles out factor length bit codes to various characters. The Greedy Choice is to allot minimum piece length code to the most incessant character.
The avaricious calculations are now and again additionally used to get an estimate for Hard advancement issues. For instance, Traveling Salesman Problem is a NP Hard issue. A Greedy decision for this issue is to pick the closest unvisited city from the present city at each progression. This arrangements doesn't generally create the best ideal arrangement, however can be utilized to get an estimated ideal arrangement.
Give us a chance to consider the Activity Selection issue as our first case of Greedy calculations. Taking after is the issue proclamation.
You are given n exercises with their begin and complete circumstances. Select the most extreme number of exercises that can be performed by a solitary individual, expecting that a man can just work on a solitary action at any given moment.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote