Netflix allows users to create individual profiles. Within each profile, users can create a list of movies that they would like to watch in the future. This is a user's "watch list". Each watch list is stored as a linked list with each node containing the title of one movie. You will write a program which allows a user to manipulate their own watch list and to combine their watch list with that of another user on the account (ie. the watch list belonging to another profile).

Your program MUST use the implementation of linked lists as described in class that is, each node is a dictionary with two keys the data key indicates the value to be stored (the movie title) and the next key points to the next node in the list. No other data should be stored in each node other than the movie title. Object-oriented solutions or other ways of representing the linked list are not permitted.

1.We will consider 2 different lists your list (profile1) and that of profile2. The two lists are stored in two different files. Your list is stored in this file, profile1.txt. The other list is stored in this file, profile2.txt. Write a function called "readFile()" that opens a given file, reads the contents and builds a linked list from the contents. To help build the list, write a function called addToEnd which has two parameters, the head of a linked list and a data value to add (in this case, this will be the title of the movie to be stored). This function will traverse the list until it finds the end and a new node containing the specified movie will be added here. The function should return the head of the (changed) linked list. The movie titles should be stored in the same order as they are in the files.

2.Put two calls to "readFile()" in main() before your menu is created -- one call to read each file and create a list for each. These are the lines of your code that we will modify so they must be there -- and there must be 2 calls, one for each data file.

3.Provide the users with a menu that offers the following choices (and implement code that performs each operation)

  • Print the list belonging to profile1.
  • Print the list belonging to profile2.
  • Merge the lists. Note that the following should happen when this option is chosen::
    • Your list should be displayed with numbers beside each item.
    • The user is prompted to enter a number the list belonging to profile2 will be added before the movie indicated by that value. The remainder of your list should be added to the end of the newly added list. (See point 4 below for an example).
    • At the end of this operation, the merged watch list will be profile1. The watch list for profile2 will be empty.
  • Remove duplicate items you and the user of profile2 may have some common tastes in movies. After merging (you dont need to check whether or not the lists have been merged), examine your list and remove any duplicate values. Leave the first occurrence of the duplicated item and remove nodes containing a repeated movie title.
  • Allow the user to add a new movie to a specified watch list (either profile1 or profile2) in a specific location. (Use the same idea as for merging -- the user enters a new movie title and a number which corresponds to an existing movie. The new movie is inserted in the list prior to the chosen movie).
  • Allow the user to delete a movie from their watch list.

Note that you should re-use code wherever possible. For instance, the first two operations can be implemented by one function. You can use the same function for displaying the list for the merge function. (It is ok to list the movies in a) and b) with numbers beside each item).

Your program should not contain any global variables. If a function manipulates one or both of the lists, they should be passed to the function as parameters.

Your program should start with a call to main() which will begin with 2 calls to "readFile" to read in the 2 data files. Next, the menu should appear allowing the user to choose from the various options.

Merging Example

Lets say Profile1s list consists of the following:

Elf -> Glee -> Divergent

Profile2s list is:

Ted -> Speed 2

Listing profile1s list would result in the following:

1. Elf
2. Glee
3. Divergent

The user wishes to insert profile2s list before Glee. So, they choose 2. The merged list (ie. profile1) is:

Elf -> Ted -> Speed 2 -> Glee -> Divergent

Listing profile2 at this point would result in:

None

No new lists should be created after you read in the initial files. All manipulation should be done by moving the pointers of the lists. You will lose marks for creating additional lists.

Hint: Write all your functions that manipulate the lists so that you pass the list as a parameter and your return value is the head of the list. You will then call the functions like this:

myNFList = newFunction(myNFList)
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.