Question

In: Computer Science

What is the greedy choice being made by Kruskal’s algorithm? Show that this choice results in...

What is the greedy choice being made by Kruskal’s algorithm? Show that this choice results in an optimal substructure.

Solutions

Expert Solution

Definition of Greedy Algorithm:

  • An algorithm is designed to achieve optimum solution for a given problem.Greedy algorithms try to find a localized optimum solution, which may eventually lead to globally optimized solutions.
  • However, generally greedy algorithms do not provide globally optimized solutions.thats why it is a optimal substructure.

Two conditions define the Greedy Paradigm:

  1. Each stepwise solution must structure a problem towards its best-accepted solution.
  2. It is sufficient if the structuring of the problem can halt in a finite number of greedy steps

Use of Greedy Approach:

  • One prominent reason is to achieve the most feasible solution immediately. In the activity selection problem , if more activities can be done before finishing the current activity, these activities can be performed within the same time

Examples of Greedy Approach :

  • Most networking algorithms use the greedy approach. Here is a list of few of them
  1. Kruskal's Minimal Spanning Tree Algorithm.
  2. Prim's Minimal Spanning Tree Algorithm.
  3. Knapsack Problem
  4. Job Scheduling Problem

Now why greedy choice been made by kruskal's algorithm:

Introduction on kruskal's algorithm:

Kruskal’s algorithm uses the greedy approach for finding a minimum spanning tree.Kruskal’s algorithm treats every node as an independent tree and connects one with another only if it has the lowest cost compared to all other options available.

Important Point: To Know Why Kruskal's Algorithm is Greedy Approach:

The Krushkal's algorithm is a Greedy Algorithm. The Greedy Choice is to pick the smallest weight edge that does not cause a cycle in the MST constructed so far.

Step to Kruskal’s algorithm:

Step 1: Sort the graph edges with respect to their weights.

Step 2: Start adding edges to the minimum spanning tree from the edge with the smallest weight until the edge of the largest weight.

Step 3: Only add edges which don’t form a cycle—edges which connect only disconnected components.

[OR]

In Simpler Form Explaination:

Step 1 – Remove all loops and parallel edges

Step 2 – Arrange all the edges in ascending order of cost

Step 3 – Add edges with least weight

Now, Why Greedy Algorithm is Optimal Substructure:

First let us know what is optimal substructure:

Optimal Substructure:

  • A problem has an optimal substructure if its optimal solution can be constructed from the optimal solutions of its subproblems.
  • Greedy algorithms try to find a localized optimum solution, which may eventually lead to globally optimized solutions.thats why Greedy Algorithm is optimal Substructure.

Related Solutions

Consider P|rj, prec|Cmax. Show that the greedy algorithm is a 2-approximation. (It pertains to Scheduling Theory,...
Consider P|rj, prec|Cmax. Show that the greedy algorithm is a 2-approximation. (It pertains to Scheduling Theory, Algorithms, and Systems.)
1.What comparison is being made in a hypothesis test? a.​Research results from a population and a...
1.What comparison is being made in a hypothesis test? a.​Research results from a population and a hypothesis about a sample ​b.Research results from a population and a hypothesis about the population ​c.Research results from a sample and a hypothesis about a population ​d.Research results from a sample and a hypothesis about the sample 2.If a sample is given a treatment and used for a hypothesis test, what would the null hypothesis (H0) say?​ ​a.The treatment causes a change in the...
Code in C# please. Write a program that will use the greedy algorithm. This program will...
Code in C# please. Write a program that will use the greedy algorithm. This program will ask a user to enter the cost of an item. This program will ask the user to enter the amount the user is paying. This program will return the change after subtracting the item cost by the amount paid. Using the greedy algorithm, the code should check for the type of bill. Example: Cost of item is $15.50 User pays a $20 bill $20...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a)...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a) No fraction allowed Max Weight W= 9 item 1: profit $20, weight 2, prof/weight=$10 item 2: profit $30, weight 5, prof/weight=$6 item 3: profit $35, weight 7, prof/weight=$5 item 4: profit $12, weight 3, prof/weight=$4 item 5: profit $3, weight 1, prof/weight=$3
Question on greedy algorithm. A sculptor starts with n metal pieces which are to be pairwise...
Question on greedy algorithm. A sculptor starts with n metal pieces which are to be pairwise forged together until one piece (the sculpture) emerges. The forging process melds two pieces into one with an energy cost directly proportional to the product of the sizes of the two pieces forged together. For example, melding three pieces of sizes x, y and z could be done in different orders, yielding different costs ( x*y + x*y*z OR x*z + x*z*y   OR y*z...
ALGORITHMS AND ANALYSIS: Show with a counterexample that the greedy approach does not always yield an...
ALGORITHMS AND ANALYSIS: Show with a counterexample that the greedy approach does not always yield an optimal solution for the Change problem when the coins are U.S. coins and we do not have at least one of each type of coin.
The​ parlor's second month results show that it made six sales at ​$25​, one at ​$48​,...
The​ parlor's second month results show that it made six sales at ​$25​, one at ​$48​, one at ​$64, three at ​$76, three at ​$107, and two at ​$121. Calculate the standard deviation for this data set. Does your answer for the standard deviation indicate that this is a normal​ distribution? If​ not, what are the​ implications? A. Yes More than​ 68% of the values are within one standard deviation from the mean. This means that future sales will not...
Show your results all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an application...
Show your results all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an application that allows a user to enter the price of an item and computes 6.25 percent sales tax on the item.
Show your results using all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an...
Show your results using all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an application that allows a user to enter the number of text messages he or she sent last month and then displays the bill. Messages cost 25 cents each, and 8 percent tax is charged on the total.
What characteristic of the binary search algorithm results in its speed? What is big O for...
What characteristic of the binary search algorithm results in its speed? What is big O for binary search? Binary search has a significant disadvantage -- what is it?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT