Question: Consider the function What AmI, whose pseudocode is given below. The algorithm takes a graph as an input and outputs either true or false. The

Consider the function What AmI, whose pseudocode is given below. The algorithm takes a
graph as an input and outputs either true or false. The algorithm also uses a global array p that
holds a Boalean value for every vinV and a global integer variable c.
input : graph G=(V,E).
output: either true or false
function What AmI (G)
for vinV do p[v]larr false;
clarr0;
for vinV do
if p[v]= false then
clarrc+1;
subWhatAmI (G,v);
if c>2 then
return true
return false
procedure subWhatAmI (G,w)
p[w]= true;
for {w,u}inE do
if p[u]= false then subWhatAmI(G,u)
Given a graph G, then the function What AmI returns true if and anly if:
G is disconnected
G has at most 2 components
G has more than 2 components
all components of G have more than two vertices
 Consider the function What AmI, whose pseudocode is given below. The

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