Question: Consider the function mystery which takes as input a list of edges in a directed graph (a list of ordered pairs of directly adjacent vertices).

Consider the function mystery which takes as input a list of edges in a directed graph (a list of ordered pairs of directly adjacent vertices). def mystery (edges): ans = edges. copy while True: old_ans = ans. copy() for ui, vi in old_ans: for u2, v2 in old_ans : if vi == u2 and (ui, v2) not in ans: ans.append((ui, v2)) if ans == old_ans : break return ans a) Given the following graph G: Find the input to mystery for this graph and find the output of mystery. What does the output of mystery signify? b) The given function mystery used a while True loop. Using your intuition from part (a), argue why the while loop will always terminate
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
