# Structure of a Greedy Algorithm:-

1. Eager decision property: A worldwide (generally speaking) ideal arrangement can be reached by picking the ideal decision at each progression.
2. Ideal foundation: An issue has an ideal base if an ideal answer for the whole issue contains the ideal answers for the sub-issues.

# Applications:-

1. Dijkstra’s Algorithm:-

# Greedy vs Divide & Conquer vs Dynamic Programming

1. Optimises by making the best choice at the moment
2. Doesn’t generally track down the ideal arrangement, yet is quick
3. Requires basically no memory
1. Upgrades by separating a subproblem into less difficult adaptations of itself and utilizing multi-stringing and recursion to address
2. Continuously tracks down the ideal arrangement, however is more slow than Greedy
3. Requires some memory to recollect recursive calls
1. Same as Divide and Conquer, yet advances by reserving the responses to each subproblem as not to rehash the computation twice.
2. Continuously tracks down the ideal arrangement, however could be inconsequential on little datasets.
3. Requires a ton of memory for remembrance/classification

# Minimum Spanning Trees Using Prim’s Algorithm:-

1. Make another tree with a solitary vertex (picked haphazardly)
2. Of the multitude of edges not yet in the new tree, track down the base weighted edge and move it to the new tree.
3. Rehash stage 2 until all vertices are in the tree

# Is Greedy Optimal? Does Greedy Always Work?

• Pick 3 divisions of coins. 1p, x, and under 2x yet more than x. We’ll pick 1, 15, 25.
• Ask for change of 2 * second denomination (15)
`[5, 0, 1]`

# Conclusion :-

--

--

--

## More from Shashwat Singh Raghav

Computer Science Student

Love podcasts or audiobooks? Learn on the go with our new app.

## Shashwat Singh Raghav

Computer Science Student