Question: #ifndef TRENDTRACKER _ H #define TRENDTRACKER _ H / / These are the only libraries you may use, / / do not include any additional
#ifndef TRENDTRACKERH
#define TRENDTRACKERH
These are the only libraries you may use,
do not include any additional libaries.
#include
#include
#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:
string
string
stringN
where string string stringN
Must run in On time.
Trendtrackerstring filename;
Return the number of hashtags in the Trendtracker.
Must run in O time.
int size;
Adds to the total number times a hashtag has been tweeted.
If the hashtag does not exist in TrendTracker, does nothing.
Must run in Ologn time.
void tweetedstring ht;
Returns the number of times a hashtag has been tweeted.
If the hashtag does not exist in Trendtracker, returns
Must run in Ologn time.
int popularitystring name;
Returns a mosttweeted hashtag.
If the Trendtracker has no hashtags, returns
Must run in O time.
string toptrend;
Fills the provided vector with the mosttweeted hashtags,
in order from mosttweeted to leasttweeted.
If there are fewer than hashtags, then the vector is filled
with all hashtags in mosttweeted to leasttweeted order
Must run in O time.
void topthreetrendsvector &T;
private:
A simple class representing a hashtag and
the number of times it has been tweeted.
class Entry
public:
string hashtag;
int pop;
;
Optional helper method.
Returns the index of E containing an Entry with hashtag ht
If no such hashtag is found, returns
Should run in Ologn
int searchstring ht;
Entries sorted lexicographically by hashtag.
vector E;
Stores indices of the up to three mosttweeted
entries in E
vector S;
;
#endif
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
