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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!