Does Max-Kruskal Algorithm Find the Maximum Spanning Tree?

  • MHB
  • Thread starter evinda
  • Start date
  • Tags
    Algorithm
In summary, the algorithm for finding the MST in a graph G orders the edges in decreasing weight and uses Kruskal's algorithm to construct a spanning tree of maximal weight. To prove its validity, we can consider a hypothetical scenario where this algorithm does not produce the MST and reach a contradiction. To prove its maximality, we can show that any other spanning tree with a higher weight would have an edge with a higher weight than the ones included in the MST, which contradicts the ordering of the algorithm.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! (Wave)

Give an algorithm that finds the MST (maximum spanning tree) of a graph $G=(V,E)$.
Prove that the algorithm you gave finds the MST.

I tried the following:

I applied the Kruskal algorithm, but instead of ordering the edges by weights in increasing order I ordered them in decreasing order.

Code:
    Max-KRUSKAL(G,w)
    1. A={}
    2. for each vertex v∈ G.V
    3.      MAKE-SET(v)
    4. sort the edges of G.E into decreasing order by weight w
    5. for each edge (u,v) ∈ G.E, taken in decreasing order by weight w
    6.      if FIND-SET(u)!=FIND-SET(v)   
    7.         A=A U {(u,v)}  
    8.         Union(u,v)
    9. return A
To prove that this algorithm finds indeed the MST, we have to prove that the algorithm produces a spanning tree and that the constructed spanning tree is of maximal weight. But could you give me a hint how we could prove the properties Spanning Tree Validity and Maximality ?
 
Technology news on Phys.org
  • #2
Or do we suppose that the algorithm does not give the maximum spanning tree, in order to get a contradiction?
 

FAQ: Does Max-Kruskal Algorithm Find the Maximum Spanning Tree?

What is an algorithm?

An algorithm is a step-by-step procedure or set of rules used to solve a problem or complete a task.

Why is it important to prove the correctness of an algorithm?

Proving the correctness of an algorithm ensures that it produces the desired output for all possible inputs, which is crucial for the reliability and effectiveness of the algorithm.

How do you prove the correctness of an algorithm?

There are several methods for proving the correctness of an algorithm, including mathematical induction, loop invariants, and structural induction. These methods involve analyzing the algorithm's logic and demonstrating that it produces the correct output for all possible inputs.

What are some common errors that can occur in algorithms?

Some common errors in algorithms include off-by-one errors, infinite loops, and logic errors. These errors can lead to incorrect outputs or the algorithm not terminating.

What are some tools and techniques used for testing the correctness of algorithms?

Some tools and techniques used for testing the correctness of algorithms include test cases, test suites, unit testing, and integration testing. These methods involve running the algorithm with various inputs and comparing the output to the expected result.

Similar threads

Replies
1
Views
1K
Replies
4
Views
2K
Replies
1
Views
1K
Replies
11
Views
3K
Replies
22
Views
5K
Replies
2
Views
2K
Replies
13
Views
3K
Back
Top