0% found this document useful (0 votes)
10 views2 pages

MST Prim Worksheet

Uploaded by

Dareen Safi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

MST Prim Worksheet

Uploaded by

Dareen Safi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MST using Prim’s Algorithm – Worksheet

Instructor: Prof. Ahmad Sharieh, Prof. Mohammad Abbadi, Dr Mohammed Khader, Mr. Abdullah
Abdalghafer 7
2
6
Apply the Prim’s algorithm on graph G from starting 9 4
from 1 , showing the priority queue Q (min-heap), the 5
arrays key[], and p[] at each step. Show the final MST and 2 3
the total cost. 8 5 8 3
Hint: use 7
 -1 instead of Nill 1 4
 99 instead of ∞

Initial Step: 1 2 3 4 5 6
Key 0 99 99 99 99 99
P -1 -1 -1 -1 -1 -1

Q 1,0 2,99 3,99 4,99 5,99 6,99


Step 1: u= 1 2 3 4 5 6
Key
P

Q
Step 2: u= 1 2 3 4 5 6
Key
P

Q
Step 3: u= 1 2 3 4 5 6
Key
P
Q
Step 4: u= 1 2 3 4 5 6
Key
P
Q
Step 5: u= 1 2 3 4 5 6
key
P
Q
Step 6: u= 1 2 3 4 5 6
Key
P
Q

Total Cost of Prim’s MST =

You might also like