You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use a binary search tree for the file table (ordered by name).
Use a hash table for the client lists.
| filename | client list |
Each client is a struct with fields ip & port.
Operations:
(n = file count, m = client count)
DIR - The file list contains only files that are 'online', so just send the list to the client. O(n)
GET - Find the requested file in the list, randomly select a client for download. O(logn)
CONNECT - Loop through the client file list, marking each available file. If the file is 'online', add the client to the file's client list (can be done during the search); Else, insert the file at the end. O(m'logm)
DISCONNECT - Loop through the file list. For each file, search the client list for the disconnecting client. If it exists, delete it. If the client list is empty, delete the file. O(m)
Create a data structure to manage available clients & files.
The text was updated successfully, but these errors were encountered: