Solution: Connecting n Pipes With Minimum Cost
This review provides a detailed analysis of how to connect n pipes with the minimum cost.
We'll cover the following...
We'll cover the following...
Solution: sorting
Explanation
If you look at the animation present in the previous lesson, you will notice that the lengths of the pipes which are picked first are included iteratively (i.e. each time). Therefore, we want them to be as small as possible. Now, let’s be greedy!
First, we initialize the priority ...