Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, please help me finish the code that is labeled TO DO in C++ Instructions: # Use the Song class (Song.h and Song.cpp) that was

Hi, please help me finish the code that is labeled TO DO in C++

Instructions:

# Use the Song class (Song.h and Song.cpp) that was created in the orientation assignment with this modification: Overload the > operator to compare song titles

# The driver is given VectorADTMain.cpp is given to you that does the following 1. Create a database of Songs called SongsData 2. Populate this database from the file SongsData.txt using push_back method 3. Sorts this database using Selection Sort with chart position as key ## Please Note the number of steps taken for this sort 4. Uses a function object from the LessThan class for sorting as above 5. Records the number of steps taken for this sort 6. Push_back and pop_back a new Song. Records the changing size of database 7. Inserts a song at index position 5. Observe successful insertion. ## Please Note the number of steps taken for this command. 8. Calls adjustInsert method to adjust chartpositions after insert //TODO 9. Remove the song from index position 4. Observes successful removal. ## Please Note the number of steps taken for this command. 10. Calls adjustRemove method to adjust chartpositions after insert //TODO 11. Create a backup of this database 12.Sort the backup using Selection sort using title as key 13.Use the LessThanEqual functor for this ## Please Note the number of steps taken for this sort 14.Search for removed song by title Record the number of steps taken for this using binary search See if this song is found ## Note the number of steps taken for this command 15. Search for inserted song by title using binary search See if this song is found ## Note the number of steps taken for this command 16.Search for last song of the database by title using binary search See if this song is found ## Note the number of steps taken for this command

VectorADTcpp.h

#include #include "VectorADT.h"

template VectorADT::VectorADT (){ dataArray= new T*[SIZE]; count=0; } //TODO Copy constructor that is called when a new vectorADT ic created and equated with the "other" ADT vector object template VectorADT::VectorADT(const VectorADT &other){ //TODO } //destructor

//TODO

template void VectorADT::resizeADT(){ size_t newSize=2*count; SIZE=SIZE*2; T ** tempADT = new T*[newSize]; for (int i=0;i void VectorADT::push_back(T *v){ //std::cout<toString(); if (count>=SIZE) resizeADT(); dataArray[count]= v; count++; } template T * VectorADT::pop(){ if (!empty()) return dataArray[count-1]; else{ throw new std::string("No such element exception"); exit(-1); } } template T * VectorADT::pop_back() { T * v = new T(); if (!empty()){ v= dataArray[count-1]; count--; return v;} else { throw new std::string("No such element exception"); exit(-1); } } template void VectorADT::printVectorADT(){ for (int i=0;i int VectorADT::size() const { return count;}

template int VectorADT::sortTitle(LessThanEqual less){ //TODO } template int VectorADT::sort(LessThan less){ int steps=0; T * minValue= new T(); int minIndex=0; for (int i=0;i bool VectorADT:: empty(){ return (count<=0); } template T* VectorADT:: get(int i) const{ if (i>=0 && i void VectorADT::set(int i, T * t){ if (i>=0 && i int VectorADT::insert(T * v, int pos){ int adjustSteps=0; if(pos >=0 && pos<=count){ if(count==SIZE){ resizeADT(); } for(int i=count-1; i>=pos; i--){ dataArray[i+1]=dataArray[i]; adjustSteps++; } dataArray[pos]=v; count++; } else{ throw new std::string("No such element exception"); exit(-1); } return adjustSteps; } template int VectorADT::remove(int pos){ int adjustSteps=0; if(pos>=0&&pos int VectorADT::binarySearchByTitle(int& steps, T * v, int first, int last){ //TODO } template int VectorADT::binarySearchByTitle(int& steps, T * v){ return binarySearchByTitle( steps, v, 0, count-1); }

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago

Question

1. Identify the sources for this conflict.

Answered: 1 week ago

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago