Question: //trendtracker.h class Trendtracker{ public: // Fills the provided vector with the k most-tweeted hashtags, // in order from most-tweeted to least-tweeted. // // If there

//trendtracker.h

class Trendtracker{

public:

// 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; };

Need help on completing this function

//trendtracker.cpp

void Trendtracker::top_k_trends(vector &T, int k){}

Tests for top_k_trends()

//main.cpp

#include #include #include #include #include #include "trendtracker.h"

//Test top_k_trends string weird = "#"; for (int i = 'a'; i <= 'z'; i++) { for (int j = 'a'; j <= 'z'; j++) { weird += i; weird += j; for (int i = 0; i < 3 * (weird[1] - 'a') + (weird[2] - 'a'); i++) T4.tweeted(weird); weird = "#"; } }

T4.top_k_trends(R, 50);

test(R[2] == "#up"); test(R[5] == "#so"); test(R[10] == "#ok"); test(R[15] == "#me"); test(R[29] == "#finishing"); test(R[32] == "#quieting");

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!