Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python BFS problem: In this problem, you'll implement a version of Facebook's friend suggestions (people you may know). Write a Python function suggest_friends (adj, s,

Python BFS problem:

In this problem, you'll implement a version of Facebook's friend suggestions ("people you may know"). Write a Python function suggest_friends (adj, s, k) where adj is the adjacency lists for an undirected graph where nodes are people and edges represent friendships, s is the index of a person, and k is a positive integer. It should return a list of exactly k people (indices) who are not s or s's friends but are as close as possible to s in the graph. You may assume there are always at least k such people. You may break ties arbitrarily; e.g., if k = 10 and s has 5 friends, 6 friends-of-friends, and 7 friends-of-friends-of-friends, then the return list should include all 6 friends-of-friends follow by any 4 of the friends-of-friends-of-friends. Your program should be a modification of BFS (breadth-first search) and run in time O (n + m).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago

Question

How is slaked lime powder prepared ?

Answered: 1 week ago

Question

Why does electric current flow through acid?

Answered: 1 week ago

Question

=+j Explain the relationship between unions and MNEs.

Answered: 1 week ago