Question: 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

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!