I want this in C programming   Phase 1 Each person eligible to win is placed in one of G groups. For each group, a process is used to narrow down the possible number of winners. The process is as follows:Let a group initially start with p people. We can number the people within a group from 1 to p and assume they are arranged in a circle(circular linked list), with 1, then 2, ..., then p, followed by 1. Each group has its own skip number, s, and its own threshold number, t, where t< p. To eliminate some people in a group from possibility of winning the lottery, start at the person labeled 1 and skip over speople in line. Then, remove the following person. (Thus the first person removed is always person number s+1.)Then repeat the process. Since the line is circular, once you pass the highest numbered person left in line, you'll continue to the lowest numbered person left in line. Continue eliminating people in this fashion until there are precisely t people left.   Phase 2 Of all of the people left, the winner of the lottery will be the lowest numbered person from any group. If there are multiple people from different groups with the same lowest number, then the person from the lowest group number is chosen as the lottery winner.The state started forcing people to come out and form lines doing the process as described, but this was extremely time consuming and they got many complaints from the losers who were forced to stand out in a big hot field for many hours before they got eliminated Now, the state has decided to hire you to simulate the process and determine who the winner will be without actually forcing all participants from standing around in circles!   The Problem Given a list of the number of groups, the initial sizes of each group, the skip value for each group and the threshold value for each group, determine the winner of the lottery (group number and person number).In addition to determining the lottery winner, you must print a log for each group of which people get eliminated (in the order that they are eliminated from contention of winning the lottery.)   The Input(to be read from standard input) The first line will contain a single positive integer, n(n≤ 25), representing the number of input cases to process.The first line of each input case will contain a single positive integer G(G≤10), representing the number of groups for the lottery selection.The following G lines will each contain information about each of the G groups. The ith of these lines will have information about group number i(1≤i≤G). The ith of these lines will have three space separated integers: pi(2 ≤pi≤10^5), si(0 ≤si

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
I want this in C programming
 
Phase 1
Each person eligible to win is placed in one of G groups. For each group, a process is used to narrow down the possible number of winners. The process is as follows:Let a group initially start with p people. We can number the people within a group from 1 to p and assume they are arranged in a circle(circular linked list), with 1, then 2, ..., then p, followed by 1. Each group has its own skip number, s, and its own threshold number, t, where t< p. To eliminate some people in a group from possibility of winning the lottery, start at the person labeled 1 and skip over speople in line. Then, remove the following person. (Thus the first person removed is always person number s+1.)Then repeat the process. Since the line is circular, once you pass the highest numbered person left in line, you'll continue to the lowest numbered person left in line. Continue eliminating people in this fashion until there are precisely t people left.
 
Phase 2
Of all of the people left, the winner of the lottery will be the lowest numbered person from any group. If there are multiple people from different groups with the same lowest number, then the person from the lowest group number is chosen as the lottery winner.The state started forcing people to come out and form lines doing the process as described, but this was extremely time consuming and they got many complaints from the losers who were forced to stand out in a big hot field for many hours before they got eliminated Now, the state has decided to hire you to simulate the process and determine who the winner will be without actually forcing all participants from standing around in circles!
 
The Problem
Given a list of the number of groups, the initial sizes of each group, the skip value for each group and the threshold value for each group, determine the winner of the lottery (group number and person number).In addition to determining the lottery winner, you must print a log for each group of which people get eliminated (in the order that they are eliminated from contention of winning the lottery.)
 
The Input(to be read from standard input)
The first line will contain a single positive integer, n(n≤ 25), representing the number of input cases to process.The first line of each input case will contain a single positive integer G(G≤10), representing the number of groups for the lottery selection.The following G lines will each contain information about each of the G groups. The ith of these lines will have information about group number i(1≤i≤G). The ith of these lines will have three space separated integers: pi(2 ≤pi≤10^5), si(0 ≤si<pi)and ti,(1 ≤ti<pi), representing the number of people in group i, the skip number for group i, and the threshold for group i, the number of people who will remain for contention to win the lottery after Phase 1 finishes for that group.The sum of si(pi-ti) over all groups will be 10^7or less. (This means that over all groups, as you simulate Phase 1, you won't have to move forward from node to node more than 10^7times.)
 
The Output(to be printed to standard out)
For each group, print the following header on a line by itself: Group#x:
where x is the 1-based number of the group.Follow this with pi-ti
integers, one per line, representing the people eliminated from contention of winning the lottery in the order in which they were eliminated.Print the information for each group in order by group number. Don't put any blank lines between the output for different groups.Follow this with a single line in the following format:
Lottery winner is person k from group g.
where k is the number of the person (1-based) and g is the group number (also 1-based) of the person who was selected to win the lottery.The total output for all cases won't exceed 10^6lines.
 
Sample Input
1
5
10 2 2
8 1 1
7 2 3
5 1 3
9 1 4
 
Sample Output
Group #1:
3
6
9
2
7
1
8
5
Group #2:
2
4
6
8
3
7
5
Group #3:
3
6
2
7
Group# 4:
2
4
Group #5:
2
4
6
8
1
Lottery winner is person 1 from group 2.
 
Implementation Restrictions/ Run-Time/Memory Restrictions
Although there is a much faster way to get the final answer, you must implement a linked list of integers to simulate the elimination process for each group.You must actually "walk" around the linked list, going node by node, to do the eliminations.You must write standard linked list functions (insert, delete) that operate on arbitrary circular linked lists. you will be able to obtain a pointer to the node to delete (and/orthe node before the one to delete).4. Your code must be modular. For each group, the same set of functions should be called, and these functions should in turn call the same linked list functions. You must free all dynamically allocated memory at the appropriate time during execution. (Memory for nodes representing all people eliminated during phase 1 should be freed as soon as it's determined that person is eliminated. Memory for nodes representing people making it past Phase 1 should be freed at the very end of the processing of each case.)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education