Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

slove by python 3 def getCommonFriends(user1, user2, network): '''(int, int, 2D list) ->int Precondition: user1 and user2 IDs in the network. 2D list sorted by

slove by python 3

def getCommonFriends(user1, user2, network): '''(int, int, 2D list) ->int Precondition: user1 and user2 IDs in the network. 2D list sorted by the IDs, and friends of user 1 and user 2 sorted Given a 2D-list for friendship network, returns the sorted list of common friends of user1 and user2 ''' common=[] # YOUR CODE GOES HERE

return common

run:

>>> getCommonFriends(3,1,net1)

[0, 9]

>>> getCommonFriends(0,112,net3)

[]

>>> getCommonFriends(217,163,net4)

[0, 100, 119, 150]

note net1.txt contains: 100 10 20 31 41 61 71 92 32 62 82 93 83 94 64 74 58 96 87 8

user 1 and 2 are inputs from the person whos running the code

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions