Question: lmplement a c++ program called trendtracker.cpp using an efficient two-vector-based data structure, representing hashtags and their popularities. Vector S stores indices of the first ten
lmplement a c++ program called trendtracker.cpp using an efficient two-vector-based data structure, representing hashtags and their popularities. Vector S stores indices of the first ten most popular hashtags of Entry items in vector E. All files are given with instructions and are not to be changed, only used to implement trendtracker.cpp. Files can all be copy/paste.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
main.cpp
#include#include #include #include #include #include "trendtracker.h" using namespace std; inline void _test(const char* expression, const char* file, int line) { cerr R; string s, line; // Test constructor, size(), popularity(), tweeted() Trendtracker T1("small.txt"); test(T1.size() == 4); test(T1.popularity("#algorithms") == 89); test(T1.popularity("#cs4all") == 19); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1965); test(T1.popularity("#C++") == 3333); T1.tweeted("#programming"); test(T1.popularity("#algorithms") == 89); test(T1.popularity("#cs4all") == 19); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1966); test(T1.popularity("#C++") == 3333); T1.tweeted("#programming"); test(T1.popularity("#algorithms") == 89); test(T1.popularity("#cs4all") == 19); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1967); test(T1.popularity("#C++") == 3333); T1.tweeted("#programming"); test(T1.popularity("#algorithms") == 89); test(T1.popularity("#cs4all") == 19); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1968); test(T1.popularity("#C++") == 3333); T1.tweeted("#cs4all"); test(T1.popularity("#algorithms") == 89); test(T1.popularity("#cs4all") == 20); test(T1.popularity("#programming") == 1968); test(T1.popularity("#C++") == 3333); T1.tweeted("#algorithms"); test(T1.popularity("#algorithms") == 90); test(T1.popularity("#cs4all") == 20); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1968); test(T1.popularity("#C++") == 3333); T1.tweeted("#cs4all"); test(T1.popularity("#algorithms") == 90); test(T1.popularity("#cs4all") == 21); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1968); test(T1.popularity("#C++") == 3333); T1.tweeted("#datastructures"); test(T1.popularity("#algorithms") == 90); test(T1.popularity("#cs4all") == 21); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1968); test(T1.popularity("#C++") == 3333); /* Test top_ten_trends().*/ Trendtracker T3("medium.txt"); T3.top_ten_trends(R); test(R.size() == 10); test(R[0] == "#linearsearch"); T3.tweeted("#convexhull"); T3.tweeted("#convexhull"); T3.top_ten_trends(R); test(R[0] == "#convexhull"); test(R[1] == "#linearsearch"); test(R[2] == "#triangulation"); for (int i = 0; i ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
trendtracker.h
#ifndef TRENDTRACKER_H #define TRENDTRACKER_H #include#include using namespace std; class Trendtracker { // For the mandatory running times below: // n is the number of hashtags in the Trendtracker. public: /* Creates a Trendtracker containing hashtags found in the provided file. The file is promised to have the following format: string1, popularity string2, popularity ... stringN, popularity where string1 &T); /* Do binary search on S by the given popularity pop; Returns the index of E containing an Entry X with X.pop equal to the given popularity pop; If no such hashtag is found, returns -1. */ int BiSearch(int pop); /* Return E[index].hashtag If index is out of range, returns " Error: Index is Out Of Range". */ string Inhashtag(int index); private: // A struct representing a hashtag and // the number of times it has been tweeted. struct Entry { public: string hashtag; int pop; }; // Entries containing each hashtag and its popularity. vector E; /* Stores indices of the ten most-tweeted entries in E. */ vector S; }; #endif //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
medium.txt
#C++,1900 #algorithms,89 #cs4all,19 #programming,1965 #datastructures,345 #binarysearch,123 #linearsearch,2018 #convexhull,2017 #triangulation,2012 #linearprogramming,1960 #nearestneighbor,1980 #lineararrange,1970 #rangesearch,1990 #voronoi,2000 #curve,1958 #motion,1989 #cnn,1943 #dog,1923 #rnn,1998 #lstm,1999////////////////////////////////////////////////////////////////////////////////////////////////
small.txt
#C++,3333 #algorithms,89 #cs4all,19 #programming,1965vector int> S4 15 string hashtag #adsl #big | #cat | #dogl #eggl #fad | #gig #hot vector
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
