Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Translate the puesodo code into C++. blockDFS(v) Connectivity in undirected graphs pred(v) num(v) i++ push edge(vu)) blockDFS(u); e pop); for all vertices u adjacent to
Translate the puesodo code into C++.
blockDFS(v) Connectivity in undirected graphs pred(v) num(v) i++ push edge(vu)) blockDFS(u); e pop); for all vertices u adjacent to v if edge(vu) not on stack if num(u) is 0 /! if there is no edge from u to /l a vertex above V, output a block /l by popping all edges off the stack // until edgetvu) is popped off if pred(u) 2 num(v) while e edge(VU) output e e pop) // e == edge(vu); output e pred(v) min(pred(V),pred(u); /I take a predecessor higher up in else if u is not the parent ofv the tree; predv) min(predv),num(u):// update when back edge(vu) is found; blockSearch0) for all vertices V num(v) = 0; while there is a vertex V such that num(v)0 blockDFS(v); Connectivity in undirectedpreda) Connectivity in undirected blockDES(a) ush edge (ac) graphs: example ush edge(ce) ckDES(e,red(e) = 3 nume 1 1)b(5,4) lockDES(d push edge(da) pred(d)min ush edge(db) 22) d(4 4) ipredid),num(a))-1 lockDFS(b push edge(bf) blockD numm h(8 8) push edge(fd) pred(h-min(pred(f),num(d)) = 4 push edge(fg) blockDFS(g) eage num(g output edge(fg) blockDFS(h) output edge( fh) pred(e)-min(pred(e)Pred( d )) push edge(fh eage(ac num(h)- pred(h) = 8 pred(b) minkpred b) pred(f output edge(fd), edge(bf), edge db) 4 red(C) min(pred(C),pred(e)) = utput edge(da), edgeled), edge(ce), edge(ac) blockDFS(v) Connectivity in undirected graphs pred(v) num(v) i++ push edge(vu)) blockDFS(u); e pop); for all vertices u adjacent to v if edge(vu) not on stack if num(u) is 0 /! if there is no edge from u to /l a vertex above V, output a block /l by popping all edges off the stack // until edgetvu) is popped off if pred(u) 2 num(v) while e edge(VU) output e e pop) // e == edge(vu); output e pred(v) min(pred(V),pred(u); /I take a predecessor higher up in else if u is not the parent ofv the tree; predv) min(predv),num(u):// update when back edge(vu) is found; blockSearch0) for all vertices V num(v) = 0; while there is a vertex V such that num(v)0 blockDFS(v); Connectivity in undirectedpreda) Connectivity in undirected blockDES(a) ush edge (ac) graphs: example ush edge(ce) ckDES(e,red(e) = 3 nume 1 1)b(5,4) lockDES(d push edge(da) pred(d)min ush edge(db) 22) d(4 4) ipredid),num(a))-1 lockDFS(b push edge(bf) blockD numm h(8 8) push edge(fd) pred(h-min(pred(f),num(d)) = 4 push edge(fg) blockDFS(g) eage num(g output edge(fg) blockDFS(h) output edge( fh) pred(e)-min(pred(e)Pred( d )) push edge(fh eage(ac num(h)- pred(h) = 8 pred(b) minkpred b) pred(f output edge(fd), edge(bf), edge db) 4 red(C) min(pred(C),pred(e)) = utput edge(da), edgeled), edge(ce), edge(ac)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