Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Change the psuedocode into an actual python program. The input is an adjacency l

ID: 3795348 • Letter: C

Question

Change the psuedocode into an actual python program. The input is an adjacency list.

Algorithm 1 Dominate (L): Set nonblack be an empty object to host non-black vertices Let ds be an empty set for hosting the dominating set: Let color be a length-n array, all of whose slots are initialized to white for each vertex i in the graph do nonblack insert (i, L[i]. length + 1) end for (v, whiteDeg) leftarrow nonblack. getmax() while whiteDeg > 0 do Save v to ds if color [v] == white then. for each neighbor j of vertex v do nonblack.decreasevalue(j, 1) end for end if for each neighbor j of vertex v do if color [j] == white then for each neighbor k vertex j do nonblack.decreaseValue (k, 1) end for color [j] leftarrow gray end if end for color[v] leftarrow back (v, whiteDeg) leftarow nonblack.getmax() end while return ds

Explanation / Answer

A)

import time
def getTextFile(set non black be an empty object to host non-black vertices):
from ds be nan emptynset for hosting he domiating set
array n=wgite;
int i;
Debug(i,L[i].length+1)
end for
(v,white deg) non black .get max()
while
{
whitedeg>0 do
save v to ds
if
color [v]==white then
for(each neighbor j of vertex v do
non black.decreasevalue(j,1)
color[j]--gray
color[v]--black
(v,white deg) non black.get max()
}
return ds

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote