Practice using searching and sorting algorithms in C++
Assignment:
This assignment will center around handling a playlist of songs. A text file (songs.txt) has been provided to you. You can use this file, or create your own. If you create your own the file should still be named "songs.txt" to be processed correctly. The text file should contain at least ten songs, containing songs that begin with a large array of letters. The text file should also contain at least one instance of songs that begin with the same word. Note the format of the given file and follow it for your own if you elect to make your own file.
The program should handle the following items: searching through binary search (by song title), sorting (by song title), and a randomized shuffle.
A starter main file has been provided to you to read in the file, along with a Song class outlining what a song is. You should use this as a starting point. The starting point creates a vector of Song type -- the processing of the file loads the songs into this vector. This is what will be sorted/shuffled/searched. Do not change the functions/class provided to you.
Your main should display a menu to the user:
Exit
Sorting
Should sort the vector of songs
Then display the items
Shuffle
Should shuffle the vector of songs
Then display the items
Search
Display warning to user (must be sorted to work properly)
Search, display whether in the vector (at what index) or if it's not
Wrong option
Your program should also contain four functions that you create:
displayPlaylist
Parameters: vector playlist (by reference)
Return values: none
Purpose: Displays the playlist
binarySearch
Parameters: vector playlist (by reference, string song title
Return values: integer
Purpose: Performs a binary search to determine if a song title is present in the vector
sort (of your choice)
Parameters: vector playlist (by reference)
Return values: none
Purpose: Choose a sorting algorithm -- use that to perform an ascending sort of the vector playlist by song title
shuffle
Parameters: vector playlist (by reference)
Return values: none
Purpose: Create a randomized shuffle algorithm to shuffle the playlist
Hints:
For the shuffle, consider using random numbers and swapping. The following libraries would be useful if using that strategy:
It is not our intention to break the school's academic policy. Posted solutions are meant to be 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 complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.