Question
You will be given a version of the Movies program (that you did for program 1) where the movies library is implemented as a linked
You will be given a version of the Movies program (that you did for program 1) where the movies library is implemented as a linked list of movie pointers instead of an array of moivie pointers. You will add a function for the following search & sort algorithms: linear search, binary search, bubble sort, insertion sort, insertion sort descending, selection sort, merge sort, and quick sort. Some of these functions will require a swap function in the LinkedList class as well. Create a function called algorithmAnalysis that will use a timer to time how long it takes to run the algorithm on a linked list of movies and print out the times. Several movie text files will be provided for you in order for you to test your program. FILES THAT SHOULD BE INCLUDED IN YOUR SUBMISSION crockett_movie_data_24.txt crockett_movie_data_112.txt crockett_movie_data_1112.txt crockett_movie_data_2112.txt crockett_movie_data_5024.txt crockett_movie_data_10112.txt Driver.cpp LinkedList.h Makefile Movie.cpp Movie.h Movies.cpp Movies.h runProgram.bat TEST_CASE_112.txt TEST_CASE_1112.txt TEST_CASE_2112.txt TEST_CASE_5024.txt Text.cpp Text.h Timer.cpp Timer.h PROGRAM SPECIFICATIONS TIMER CLASS Whenever you see start timer and stop timer and print out total time in the directions in this document, that means you will be using the Timer class provided for you. You will need to #include Timer.h to use this class. When you want to use a timer in your program, you will first need to create variables of data type time_t. time_t start; time_t end; The getTime() function will get the current time and return it as a time_t data type. You will use this function to get the start time and the end time. The totalTime() function accepts two time_t variables (start & end) and then returns the difference as a double (which is the number of seconds between the start & end time. DRIVER.CPP Modify the menu so that there is an addition option. The option should be inserted after Print all movies and before Delete All movies and will be your new #7. Then the user will choose between 1 and 8. If the user chooses #7, then you should call the algorithmAnalysis function, which is a member function of the Movies class. MOVIES CLASS Create the functions described below. All of the following functions except for algorithmEfficiency() should be made private. o linearSearch This function should search for a particular movie title to see if it is in the list. It should return -1 if the Movie title could not be found. Use the linear search algorithm to implement this function. o binarySearch - This function should search for a particular movie title to see if it is in the list. It should return -1 if the Movie title could not be found. Use the binary search algorithm to implement this function. o bubbleSort This function should sort the LinkedList of Movies in ascending order by Movie title. This function will call a function called swap in the linkedList class to swap values in the linked list when necessary. Use the bubble sort algorithm to implement this function. o insertionSort - This function should sort the LinkedList of Movies in ascending order by Movie title. This function will call a function called swap in the linkedList class to swap values in the linked list when necessary. Use the insertion sort algorithm to implement this function. o insertionSortDescending This function should be the same as insertionSort except it will sort the LinkedList of Movies in descending order by Movie title instead of ascending order. o selectionSort - This function should sort the LinkedList of Movies in ascending order by Movie title. This function will call a function called swap in the linkedList class to swap values in the linked list when necessary. Use the selection sort algorithm to implement this function. o mergeSort & merge These two functions work together to implement the merge sort algorithm, which should sort the LinkedList of Movies in ascending order by Movie title. The mergeSort function is a recursive function which calls the merge function. The merge function dynamically allocates a new linked list of Movie pointers to use as the merged linked list. At some point in the merge function you will need to replace a node.you will do this by deleting the node (deleteNode) at a particular position and then inserting a new node (insertNode function) at a particular position. quickSort & partition These two functions work together to implement the quick sort algorithm, which should sort the LinkedList of Movies in ascending order by Movie title. The quicksort function is a recursive function which calls the partition function. The partition function will use a pivot string (c-string). The partition function will call a function called swap in the linkedList class to swap values in the linked list when necessary. o algorithmAnalysis- This is the driver function that will call all of these other functions to test the efficiency of each one. Here is the pseudocode for this function below: 1. Start timer Call linearSearch sending a temporary Text* with a c-string named Llama to it. (I dont care if It finds this string or not) Stop timer Print out total time for this algorithm 2. Start timer Call binarySearch() sending a temporary Text* with a c-string named Llama to it. Stop timer Print out total time for this algorithm 3. Call insertionSortDescending() to put linked list in opposite order. Start timer Call bubbleSort() Stop timer Print out total time for this algorithm 4. Call insertionSortDescending() to put linked list in opposite order. Start timer Call selectionSort() Stop timer Print out total time for this algorithm 5. Call insertionSortDescending() to put linked list in opposite order. Start timer Call insertionSort() Stop timer Print out total time for this algorithm 6. Start timer Call insertionSortDescending() Stop timer Print out total time for this algorithm 7. Start timer Call mergeSort() sending 0 and the length of the linked list (# of nodes) minus 1 to the function Stop timer Print out total time for this algorithm 8. Start timer Call quickSort() sending 0 and the length of the linked list (# of nodes) minus 1 to the function Stop timer Print out total time for this algorithm LINKEDLIST CLASS Add a function to the LinkedList template class (LinkedList.h) called swap. This function should accept two integers which represent two node positions that need to be swapped. This function should swap the VALUES in the two nodes. You do not have to swap the whole node, just swap the values.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started