Question: Question#include#include#include#include#includeusing namespace std;struct Page { int id; string path; int counter; Page(int id, string path) { this->id = id; this->path = path; counter = 0;

Question#include#include#include#include#includeusing namespace std;struct Page { int id; string path; int counter; Page(int id, string path) { this->id = id; this->path = path; counter = 0; };};// This function can facilitate sortingbool operatorid = id; }; void add_visit(int page_id) { Page p(page_id, ""); vector::iterator iter = lower_bound(pages.begin(), pages.end(), p); if(iter->id == page_id) visits.push_back(iter->path); }; int size() const { return visits.size(); }; void print_visits() { sort(visits.begin(), visits.end()); vector::iterator iter; for(iter = visits.begin(); iter != visits.end(); iter++) { cout > type) { if(type == "USER") { int user_id; cin >> user_id; User u(user_id); add_user(u); } else if(type == "PAGE") { int page_id; string page_path; cin >> page_id; cin >> page_path; Page p(page_id, page_path); add_page(p); } else if(type == "VISIT") { int page_id; cin >> page_id; Page p(page_id, ""); vector::iterator iter = lower_bound(pages.begin(), pages.end(), p); if(iter->id == p.id) { iter->counter++; } add_visit(p.id); } } sort(pages.begin(), pages.end(), cmp_page_count); cout

Question#include#include#include#include#includeusing namespace std;struct Page { int id; string path; int counter; Page(int

Problem 1: Game of Elimination in C++ Consider a prize to be awarded to a winner among n > 0 contestants by a game of elimination. The n contestants first line up in a line, and are assigned the numbers 1 to n one by one. The host of the game then decides on an integer k > 1, and starting from contestant 1, the host counts k contestants down the line and eliminates the k-th contestants from the circle. He then continues to count for another k contestants. and eliminates the k-th contestants from the line. When he counts to the end of line, he will continue counting from the beginning of the line. This process repeats until there is only one contestant remains who will be the winner of the prize. For example, if n = 7 and k = 3. The initial line: 1234567, count to 3 and contestant 3 is eliminated Line now becomes: 124567. continue counting from 4 and contestant 6 is eliminated Line now becomes: 12457, continue counting from 7 and contestant 2 is eliminated Line now becomes 1457. continue counting from 4 and contestant 7 is eliminated Line now becomes 145, continue counting from 1 and contestant 5 is eliminated Line now becomes 14, continue counting from 1 and contestant 1 is eliminated Winner is contestant 4 Write a C++ proglam which impiements a circular linked list (see Module 8 Guidance Notes p.92) to determine which contestant will win the prize. Program input. Two input numbers n and k {n > 0 and k > 1). Program output. The winner of the game. Requirement: You will need to implement the circular linked list on your own, i.e., you may NOT use any STL containers or external linked list iibraries

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 Programming Questions!