Search for question
Question

questionNo

Comment

3 Interpreting code (7 marks):

One of the main skills of 162 is being able to read and write code. For this question you will download

the function MysteryGraph.m from the assignment page, and will explain and interpret it.

a) Run MysteryGraph for a variety of inputs. What do you observe?

b) Explain in plain language what is happening inside the MysteryGraph function. You'll probably

want one or two sentences explaining each section of the program.

c) What happens if you run MysteryGraph (1,2)? Can you explain why this occurs? What part of

the code is causing this and why?

Hint: It may be useful to remember the CTRL+C command. If you get lost, setting up break

points at stepping through line by line may also

prove helpful.

d) Suppose you have a random graph generated by MysteryGraph. Does this graph have an Eulerian

Circuit, sometimes, always or never? Does it have a Hamiltonian Circuit sometimes, always, or

never? Give a one sentence justification for each of your answers.

e) Bonus question (0 marks) If I run the code Mystery Graph (5,5), is it possible for node 4 to

be connected to itself? Why or why not? What if I run MysteryGraph (4,4), instead?

Fig: 1