Question: In Algorithm (4b), we decide if a given directed graph G contains a directed cycle or not. Fill missing the missing pseudo-codes in block (4bi),

In Algorithm (4b), we decide if a given directed graph G contains a directed cycle or not. Fill missing the missing pseudo-codes in block (4bi), and choose the right statement from the following two options for (4bii): A: if i=n then return "yes" else return "no". B: if i=n then return "no" else return "yes". Again, we assume G does not contain parallel edges or self-loops. \begin{tabular}{ll} \hline Algorithm (4b) deciding if a directed graph G contains a cycle or not & \\ \hline 1: for every vV do let dv0 & \\ 2: for every edge (v,u) in G do dudu+1 & \\ 3: i0, top 0,S an array of size n & \\ 4: for every vV with dv=0 do top top +1,S[top]v & \\ 5: for every vV do let (v) be undefined & \\ 6: while top >0 do & \\ 7:vS[top], top top -1 & \\ 7:ii+1,(v)i & \\ 8: for every outgoing edge (v,u) of v in G do & \\ 9: & \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
