Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started