Question: NOTE: Do NOT modify main.cpp file to alter or bypass the objective. Must compile! ------------ main.cpp file #include #include #include #include #include #include trendtracker.h using


NOTE: Do NOT modify main.cpp file to alter or bypass the objective. Must compile!
------------ main.cpp file
#include #include #include #include #include #include "trendtracker.h" using namespace std; inline void _test(const char* expression, const char* file, int line) { cerr ------------
------------ 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 new Trendtracker tracking no hashtags. // // Must run in O(1) time. Trendtracker(); // Inserts a hashtag (tweeted 0 times) into the Trendtracker. // If the hashtag already is in Trendtracker, does nothing. // // Must run in O(n) time. void insert(string ht); // Return the number of hashtags in the Trendtracker. // // Must run in O(1) time. int size(); // Adds 1 to the total number times a hashtag has been tweeted. // If the hashtag does not exist in TrendTracker, does nothing. // // Must run in O(n) time. void tweeted(string ht); // Returns the number of times a hashtag has been tweeted. // If the hashtag does not exist in Trendtracker, returns -1. // // Must run in O(n) time. int popularity(string name); // Returns a most-tweeted hashtag. // If the Trendtracker has no hashtags, returns "". // // Must run in O(n) time. string top_trend(); // Fills the provided vector with the 3 most-tweeted hashtags, // in order from most-tweeted to least-tweeted. // // If there are fewer than 3 hashtags, then the vector is filled // with all hashtags (in most-tweeted to least-tweeted order). // // Must run in O(n) time. void top_three_trends(vector &T); // Remove the given hashtag from the trendtracker. // // Must run in O(n) time. void remove(string ht); // Fills the provided vector with the k most-tweeted hashtags, // in order from most-tweeted to least-tweeted. // // If there are fewer than k hashtags, then the vector is filled // with all hashtags (in most-tweeted to least-tweeted order). // // Must run in O(nk) time. void top_k_trends(vector &T, int k); private: // A simple class representing a hashtag and // the number of times it has been tweeted. class Entry { public: string hashtag; int pop; }; // Entries containing each hashtag and its popularity. vector E; }; #endif ---------
Please submit photo of output with 'Assignment complete'. (For trendtracker.h functions, please make use of those only)
The Twitter website has become a de facto first source for many important events in the last decade. Twitter's hashtag feature lets users tag tweets with single words or phrases (e.g. #superbowl, #algorithms, or #vacaciones). Popular or trending hashtags indicate strong shared interest by many people in a topic, and tracking these trends is of interest to businesses, news outlets, and researchers. string hashtag vector E- #cat #gig #hot #fad #ads #egg #big #dog 2 1 6 2 9 8 0 int pop Figure 1: Representing hashtags and their popularities using a vector-based data structure. In this homework, you'll implement an vector-based data structure that tracks information about a collection of hashtags, including which are most popular, i.e. are trending. The following files have been given to you: 1. A C++ header file (trendtracker.h) declaring the Trendtracker class. 2. A C++ source file (main.cpp) containing a main function with tests. 3. A text file (common.txt) containing 3612 common English words.? Download the files at: common.txt main.cpp trendtracker.h Create a new C++ source file named trendtracker.cpp that implements the Trendtracker class, so that trendtracker.cpp and the provided files compile into a program that runs with no failed tests. Submit the source file trendtracker.cpp Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
