Question: Make sure to read carefully. You may write procedures in pseudocode or in any programming language the TA s know. Procedures can use helpers .

Make sure to read carefully. You may write procedures in pseudocode or in any programming language the TAs know. Procedures can use helpers. Anadjacency structureis what Cormen mistakenly calls anadjacency liston page550.
1.(15 points.) Suppose thatGis a directed graph. It has an adjacency structureG.Adj,a set of edgesG.E,and a set of vertexesG.V.Each vertexvG.Vhas an attributev.mark{TRUE,FALSE}. It has no other attributes! In particular, it has nocolor, d, f,orattributes like Cormens vertexes do.
A vertexvG.Vis anorigin vertexinGif there is exactly one path fromvto every other vertex inG.V. The wordoriginis meant to suggest that every vertex inGis reachable starting fromv.Dont bother looking fororigin vertexonline: the only hits you will get are irrelevant to this question: they deal with parabolas from high-school algebra.
Write a procedure IS-ORIGIN(G,u) that returnsTRUEif the vertexuis an origin in the graphG,and returnsFALSEotherwise. Your procedure must always terminate, even ifGhas cycles or self edges. You will lose many points if it uses vertex attributes other thanmark

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 Programming Questions!