#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...

1 answer below »
I need help completing my coding assignment


#include #include #include #include #include #include "trendtracker.h" using namespace std; inline void _test(const char* expression, const char* file, int line) { cerr < "test("="">< expression="">< ")="" failed="" in="" file="" "="">< file;="" cerr="">< ",="" line="" "="">< line="">< "."="">< endl;="" abort();="" }="" #define="" test(expression)="" ((expression)="" (void)0="" :="" _test(#expression,="" __file__,="" __line__))="" int="" main()="" {="" setup=""> R; string s, line; // Test constructor, size(), popularity(), tweeted() Trendtracker T1("small.txt"); test(T1.size() == 4); test(T1.popularity("#algorithms") == 0); test(T1.popularity("#cs4all") == 0); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 0); test(T1.popularity("#C++") == 0); T1.tweeted("#programming"); test(T1.popularity("#algorithms") == 0); test(T1.popularity("#cs4all") == 0); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 1); test(T1.popularity("#C++") == 0); T1.tweeted("#programming"); test(T1.popularity("#algorithms") == 0); test(T1.popularity("#cs4all") == 0); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 2); test(T1.popularity("#C++") == 0); T1.tweeted("#programming"); test(T1.popularity("#algorithms") == 0); test(T1.popularity("#cs4all") == 0); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 3); test(T1.popularity("#C++") == 0); T1.tweeted("#cs4all"); test(T1.popularity("#algorithms") == 0); test(T1.popularity("#cs4all") == 1); test(T1.popularity("#programming") == 3); test(T1.popularity("#C++") == 0); T1.tweeted("#algorithms"); test(T1.popularity("#algorithms") == 1); test(T1.popularity("#cs4all") == 1); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 3); test(T1.popularity("#C++") == 0); T1.tweeted("#cs4all"); test(T1.popularity("#algorithms") == 1); test(T1.popularity("#cs4all") == 2); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 3); test(T1.popularity("#C++") == 0); T1.tweeted("#datastructures"); test(T1.popularity("#algorithms") == 1); test(T1.popularity("#cs4all") == 2); test(T1.popularity("#datastructures") == -1); test(T1.popularity("#programming") == 3); test(T1.popularity("#C++") == 0); Trendtracker T2("small.txt"); T2.tweeted("#programming"); T2.tweeted("#programming"); T2.tweeted("#programming"); T2.tweeted("#programming"); T2.tweeted("#programming"); T2.tweeted("#C++"); T2.tweeted("#C++"); T2.tweeted("#C++"); T2.tweeted("#C++"); T2.tweeted("#cs4all"); T2.tweeted("#cs4all"); T2.tweeted("#cs4all"); T2.tweeted("#algorithms"); T2.tweeted("#algorithms"); test(T2.popularity("#algorithms") == 2); test(T2.popularity("#cs4all") == 3); test(T2.popularity("#programming") == 5); test(T2.popularity("#C++") == 4); // Enforce no usage of global variables test(T1.popularity("#algorithms") == 1); test(T1.popularity("#cs4all") == 2); test(T1.popularity("#programming") == 3); test(T1.popularity("#C++") == 0); // Test top_trend(), top_three_trends() Trendtracker T3("small.txt"); T3.top_three_trends(R); test(R.size() == 3); T3.tweeted("#programming"); test(T3.top_trend() == "#programming"); T3.top_three_trends(R); test(R.size() == 3); test(R[0] == "#programming"); T3.tweeted("#C++"); T3.tweeted("#C++"); test(T3.top_trend() == "#C++"); T3.top_three_trends(R); test(R.size() == 3); test(R[0] == "#C++"); test(R[1] == "#programming"); T3.tweeted("#algorithms"); T3.tweeted("#algorithms"); T3.tweeted("#algorithms"); test(T3.top_trend() == "#algorithms"); T3.top_three_trends(R); test(R.size() == 3); test(R[0] == "#algorithms"); test(R[1] == "#C++"); test(R[2] == "#programming"); T3.tweeted("#cs4all"); T3.tweeted("#cs4all"); T3.tweeted("#cs4all"); T3.tweeted("#cs4all"); test(T3.top_trend() == "#cs4all"); T3.top_three_trends(R); test(R.size() == 3); test(R[0] == "#cs4all"); test(R[1] == "#algorithms"); test(R[2] == "#C++"); // At this point: // cs4all: 4 // algorithms: 3 // C++: 2 // programming: 1 T3.tweeted("#programming"); T3.tweeted("#programming"); T3.tweeted("#programming"); T3.tweeted("#programming"); test(T3.top_trend() == "#programming"); T3.top_three_trends(R); test(R.size() == 3); test(R[0] == "#programming"); test(R[1] == "#cs4all"); test(R[2] == "#algorithms"); // At this point: // programming: 5 // cs4all: 4 // algorithms: 3 // C++: 2 T3.tweeted("#cs4all"); T3.tweeted("#cs4all"); T3.tweeted("#algorithms"); test(T3.top_trend() == "#cs4all"); T3.top_three_trends(R); test(R.size() == 3); test(R[0] == "#cs4all"); test(R[1] == "#programming"); test(R[2] == "#algorithms"); // At this point: // cs4all: 6 // programming: 5 // algorithms: 4 // C++: 2 for (int i = 0; i < 10000;="" ++i)="" t3.tweeted("#c++");="" test(t3.top_trend()="=" "#c++");="" t3.top_three_trends(r);="" test(r.size()="=" 3);="" test(r[0]="=" "#c++");="" test(r[1]="=" "#cs4all");="" test(r[2]="=" "#programming");="" trendtracker="" t4("hashtags.txt");="" test(t4.size()="=" 300000);="" ifstream="" f;="" f.open("tweeted.txt");="" assert(f.is_open());="" if="" this="" fails,="" you're="" missing="" tweeted.txt="" while="" (getline(f,="" line))="" t4.tweeted(line);="" f.close();="" test(t4.popularity("#programming")="=" 10);="" test(t4.popularity("#computer")="=" 9);="" test(t4.popularity("#is")="=" 8);="" test(t4.popularity("#very")="=" 7);="" test(t4.popularity("#fun")="=" 6);="" test(t4.popularity("#but")="=" 5);="" test(t4.popularity("#sometimes")="=" 5);="" test(t4.popularity("#can")="=" 5);="" test(t4.popularity("#be")="=" 5);="" test(t4.popularity("#challenging")="=" 5);="" test(t4.top_trend()="=" "#programming");="" t4.top_three_trends(r);="" test(r[0]="=" "#programming");="" test(r[1]="=" "#computer");="" test(r[2]="=" "#is");="" test="" a="" trendtracker="" with="" a="" single="" hashtag="" trendtracker="" t5("tiny.txt");="" test(t5.size()="=" 1);="" test(t5.popularity("#solo")="=" 0);="" test(t5.popularity("#duo")="=" -1);="" t5.tweeted("#solo");="" test(t5.popularity("#solo")="=" 1);="" test(t5.popularity("#duo")="=" -1);="" test(t5.top_trend()="=" "#solo");="" t5.top_three_trends(r);="" test(r.size()="=" 1);="" test(r[0]="=" "#solo");="" cout="">< "assignment="" complete."="">< endl;="" }="" #c++="" #algorithms="" #cs4all="" #programming="" csci="" 3333="" homework="" tt2:="" fast="" trendtracker="" 1="" introduction="" in="" the="" previous="" homework,="" you="" implemented="" a="" trendtracker="" data="" structure="" that="" tracks="" information="" about="" a="" set="" of="" hashtags.="" unfortunately,="" the="" efficiency="" of="" data="" structure’s="" operations="" (tweeted,="" popularity,="" top="" three="" trends,="" etc.)="" probably="" wasn’t="" great.="" for="" tracking="" a="" few="" thousand="" hashtags,="" the="" efficiency="" was="" good="" enough,="" but="" twitter="" has="" hundreds="" of="" millions="" of="" users1="" using="" millions="" of="" distinct="" hashtags.2="" so="" for="" this="" homework,="" you="" will="" implement="" the="" same="" class,="" but="" using="" an="" efficient="" two-vector-based="" data="" structure="" (see="" figure="" 1).="" #ads="" 2=""> S vector E 4 1 5 #gig 2 #hot 1 #dog 0 #cat 4 #fad 6 #big 8 #egg 9 string hashtag int pop Figure 1: Representing hashtags and their popularities using an efficient vector-based data structure. 2 Instructions 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 ( tiny.txt) containing 1 hashtag. 4. A text file (small.txt) containing 4 hashtags. 5. A text file (hashtags.txt) containing 300000 hashtags.3 6. A text file (tweeted.txt) containing 1500000 hashtags.4 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. 3 Submission and Grading Submit the aforementioned source file(s) via Blackboard as attached file(s). In the case of multiple submis- sions, the last submission before the deadline is graded. For grading, each submission is compiled with the provided files and run. Submissions that do not run to completion (i.e. fail to print “Assignment complete.”) receive no credit. Submissions that take an unreasonable amount of time (e.g. more than a minute or so) to run and do not meet the asymptotic efficiency requirements receive no credit. All other submissions receive full credit. See the course late work policy for information about receiving partial credit for late submissions. 1https://techcrunch.com/2017/06/27/facebook-2-billion-users/ 2http://iswc2010.semanticweb.org/pdf/352.pdf 3Source: http://norvig.com/ngrams/count_1w.txt. 4Source: http://norvig.com/ngrams/count_1w.txt. 1 https://faculty.utrgv.edu/robert.schweller/CS3333/hwTT2/trendtracker.h https://faculty.utrgv.edu/robert.schweller/CS3333/hwTT2/main.cpp https://faculty.utrgv.edu/robert.schweller/CS3333/hwTT2/tiny.txt https://faculty.utrgv.edu/robert.schweller/CS3333/hwTT2/small.txt https://faculty.utrgv.edu/robert.schweller/CS3333/hwTT2/hashtags.txt https://faculty.utrgv.edu/robert.schweller/CS3333/hwTT2/tweeted.txt https://techcrunch.com/2017/06/27/facebook-2-billion-users/ http://iswc2010.semanticweb.org/pdf/352.pdf http://norvig.com/ngrams/count_1w.txt http://norvig.com/ngrams/count_1w.txt Introduction Instructions Submission and Grading
Answered 3 days AfterSep 11, 2022

Answer To: #include #include #include #include #include #include "trendtracker.h" using namespace std; inline...

Jitendra answered on Sep 14 2022
72 Votes
$ g++ -g main.cpp trendtracker.cpp trendtracker.h
$ ./a.out
Assignment complete.
$
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here