Question: I need help with an SML Coding Project I am working on for my Discrete Math II class. I ' m given an SML function

I need help with an SML Coding Project I am working on for my Discrete Math II class. I'm given an SML function where I need to fill in the if-then-else statements. Here is the function below:
fun bfsVisit(g, v, found, bfsEdges, workList)=
let val adj = getAdjacent(g, v);
fun step(u,(found2, bfsEdges2, workList2))=
if ??
then ??
else ??;
in foldl(step)(found, bfsEdges, workList)(adj)
end;
This code also uses the following datatypes and the exception:
datatype vertex = V of int * int list;
datatype graph = G of vertex list;
exception NoSuchVertex;
It also uses these helper functions:
fun getAdjacent(G([]), v)= raise NoSuchVertex
| getAdjacent(G(V(u, adj)::rest), v)=
if u = v then adj else getAdjacent(G(rest), v);
fun contains([], x)= false
| contains(y::rest, x)= y = x orelse contains(rest, x);
As you fill out the if-then-else statements, please also provide a list of sample outputs I can use for the function so I can get a better understanding of what to do. Thank you.

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!