Question: 5. Rewrite the degreeofseparation method from Section 22.2 without recursion. people, Person pl, Person p2, int n) if (n1) // Base case return pl.knows (p2)

 5. Rewrite the degreeofseparation method from Section 22.2 without recursion. people,

Person pl, Person p2, int n) if (n1) // Base case return

5. Rewrite the degreeofseparation method from Section 22.2 without recursion. people, Person pl, Person p2, int n) if (n1) // Base case return pl.knows (p2) else if (n2) // Another base case for (Person p : people) if (p1.knows (p) && p.knows (p2)) return true; return false; else // Recursive case int m-n/2; for (Person p people) if (degreeOfSeparation (people, pl, p, m) && degreeofSeparation (people, p, p2, n-m)) return true; return false

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!