Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help. Thank you so much! CODE USING C++ PROGRAMMING LANGUAGE --------------------------------------------------------------------- DO NOT USE any of the STL (including the stack and queue type)

Please help. Thank you so much!

CODE USING C++ PROGRAMMING LANGUAGE ---------------------------------------------------------------------

DO NOT USE any of the STL (including the stack and queue type) in your code.

------------------------------------------------------------------------------------------------------------

Binary Search Tree (BST)

You will be implementing a BST using a linked representation to store the top songs on Billboard. The class should be named SongBST. TreeNode with an array

TreeNode will hold information about each song including the dates it appeared on the Billboard chart. These dates will be stored in a static array dates, and frequency indicates how many times the song appeared on the chart.

struct TreeNode{ string title; //used as key string artist; string dates[52]; //filled starting from index 0 int frequency; //should match # of elements in dates TreeNode* left; TreeNode* right; };

Reading in Songs

The list of songs to add to the tree will be in top.csv . Discard the first line of the file in the driver, then read in each song. Pass all the information to the SongBST insert function to add each song to the tree. The nodes in the tree should be ordered by song title.

BST Functions

Implement all basic class functions (default constructor, copy constructor, destructor, copy assignment) and basic tree functions: void insert(string title, string artist, string date): creates and adds a TreeNode to thetree. Set the first index of dates to the date that is passed in. If the song is already in the tree, update frequency and dates accordingly. You can assume that two songs wont have the same title.

bool remove(string title): returns false if the song is not in the tree.

Implement the following functions: 1. print(): prints the title and frequency of all the songs in the tree using an inorder traversal.

2. printSong(string title): finds and prints all the information about the song. See execution example for the print format.

3. int topSong(): returns the maximum number of times a single song appeared on the chart (i.e. highest frequency in the tree) using recursion.

The SongBST class should be in two files named songbst.h and songbst.cpp.

Execution example

Hello! Processing the top.csv file. 
Printing tree: All I Want For Christmas Is You x 3 Blinding Lights x 4 Cardigan x 1 Circles x 1 Dynamite x 3 Franchise x 1 Life Goes On x 1 Mood x 6 Positions x 1 Rain On Me x 1 Rockstar x 7 Savage x 1 Savage Love (Laxed - Siren Beat) x 1 Say So x 1 Stuck With U x 1 The Box x 11 The Scotts x 1 Toosie Slide x 1 Trollz x 1 WAP x 4 Watermelon Sugar x 1 

Which song do you want to print? All I Want For Christmas Is You

Title: All I Want For Christmas Is You Artist: Mariah Carey Appeared on the Billboard chart 3 times on: 2020-01-04 2020-01-11 2020-12-26 
Which song do you want to remove? The Box The Box has been removed. Printing updated tree: 
All I Want For Christmas Is You x 3 Blinding Lights x 4 Cardigan x 1 Circles x 1 
Dynamite x 3 Franchise x 1 Life Goes On x 1 Mood x 6 Positions x 1 Rain On Me x 1 Rockstar x 7 Savage x 1 Savage Love (Laxed - Siren Beat) x 1 Say So x 1 
Stuck With U x 1 The Scotts x 1 Toosie Slide x 1 Trollz x 1 WAP x 4 Watermelon Sugar x 1 
The top song appeared 7 times on Billboard 100. 

CSV FILE: top.csv

title,artist,date All I Want For Christmas Is You,Mariah Carey,2020-01-04 All I Want For Christmas Is You,Mariah Carey,2020-01-11 Circles,Post Malone,2020-01-18 The Box,Roddy Ricch,2020-01-25 The Box,Roddy Ricch,2020-02-01 The Box,Roddy Ricch,2020-02-08 The Box,Roddy Ricch,2020-02-15 The Box,Roddy Ricch,2020-02-22 The Box,Roddy Ricch,2020-02-29 The Box,Roddy Ricch,2020-03-07 The Box,Roddy Ricch,2020-03-14 The Box,Roddy Ricch,2020-03-21 The Box,Roddy Ricch,2020-03-28 The Box,Roddy Ricch,2020-04-04 Blinding Lights,The Weeknd,2020-04-11 Blinding Lights,The Weeknd,2020-04-18 Toosie Slide,Drake,2020-04-25 Blinding Lights,The Weeknd,2020-05-02 Blinding Lights,The Weeknd,2020-05-09 The Scotts,"THE SCOTTS - Travis Scott & Kid Cudi",2020-05-16 Say So,Doja Cat Featuring Nicki Minaj,2020-05-23 Stuck With U,Ariana Grande & Justin Bieber,2020-05-30 Savage,Megan Thee Stallion,2020-06-06 Rain On Me,Lady Gaga & Ariana Grande,2020-06-13 Rockstar,DaBaby Featuring Roddy Ricch,2020-06-20 Rockstar,DaBaby Featuring Roddy Ricch,2020-06-27 Trollz,6ix9ine & Nicki Minaj,2020-07-04 Rockstar,DaBaby Featuring Roddy Ricch,2020-07-11 Rockstar,DaBaby Featuring Roddy Ricch,2020-07-18 Rockstar,DaBaby Featuring Roddy Ricch,2020-07-25 Rockstar,DaBaby Featuring Roddy Ricch,2020-08-01 Rockstar,DaBaby Featuring Roddy Ricch,2020-08-08 Cardigan,Taylor Swift,2020-08-15 Watermelon Sugar,Harry Styles,2020-08-22 WAP,Cardi B Featuring Megan Thee Stallion,2020-08-29 WAP,Cardi B Featuring Megan Thee Stallion,2020-09-05 Dynamite,BTS,2020-09-12 Dynamite,BTS,2020-09-19 WAP,Cardi B Featuring Megan Thee Stallion,2020-09-26 WAP,Cardi B Featuring Megan Thee Stallion,2020-10-03 Dynamite,BTS,2020-10-10 Franchise,Travis Scott Featuring Young Thug & M.I.A.,2020-10-17 Savage Love (Laxed - Siren Beat),Jawsh 685 x Jason Derulo,2020-10-24 Mood,24kGoldn Featuring iann dior,2020-10-31 Mood,24kGoldn Featuring iann dior,2020-11-07 Positions,Ariana Grande,2020-11-14 Mood,24kGoldn Featuring iann dior,2020-11-21 Mood,24kGoldn Featuring iann dior,2020-11-28 Mood,24kGoldn Featuring iann dior,2020-12-05 Life Goes On,BTS,2020-12-12 Mood,24kGoldn Featuring iann dior,2020-12-19 All I Want For Christmas Is You,Mariah Carey,2020-12-26

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

How was their resistance overcome?

Answered: 1 week ago