I want this in C   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

Question
I want this in C
 
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 Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Engineering

Theory of Computation

Programing

Related Computer Engineering Q&A

Find answers to questions asked by students like you.

Q: Mars moves in an elliptical orbit around the sun, and the mass of Mars is much less than the mass of...

A: here we can use Kepler's orbital law  We know that potential energy between two planets can be found...

Q: Which of the following cannot be considered a benefit of implementing HACCP?-increase in quality pre...

A: HACCP schooling and high turnover of workers and on farm it might build the disinfection and wellbei...

Q: Write a program that reads the student information from a tab separated values (tsv) file. The progr...

A: Answer:Code 1- try: # opening file for reading fileread= open("StudentInfo.tsv") # opening file for ...

Q: The figure below represents the market for Gasoline, where initially the equilibrium price was $5.60...

A: According to the given information, it can be said that: Initial price for consumers is $5.60 Final...

Q: When using LinkedIn, this term is used to describe the people with which you want to communicate.   ...

A: Please find the answer below :

Q: Identify ONE state in Latin America or Africa, other than Chile, in which global geopolitical circum...

A: As a nation, Chile experienced imperial domination by Spain from mid 16th to early 19th century, gai...

Q: Metro City enacts an ordinance that bans the use of “sound amplifying systems” on public streets. Ni...

A: The citizens should get liberty and freedom still, they have to use it respectably and peacefully wi...

Q: The average wholesale price a company is charging camera retailers for its models is deemed to be "c...

A: The question is based on the concept of Accounting theory.

Q: Balance sheetDynamic Weight Loss Co. offers personal weight reduction consultingservices to individu...

A: the balance sheet is the financial statement which represents the financial position of the business...

Q: The question “What was the best idea you ever sold to a boss or coworker?” would be used in a(n) Mu...

A: The purpose of behavioural interview questions is to understand who you are, how you think, and how ...

Q: Ida's ice-cream stand has increasing profits each week during the hot summer months. Ida finds that ...

A: Given- Ida's ice-cream stand has increasing profits each week during the hot summer months. Ida find...

Q: 6.27 LAB: Toll calculation Use Java programming. Toll roads have different fees based on the time of...

A: public class Calculationoftoll {       public double toll_calculate(int hour, boolean isMorning, boo...

Q: Back to Assignment Attempts Average /5 Working with Numbers and Graphs Q9 The following table summar...

A: Opportunity cost of Nicki Kamal X 30/300 = 1/10=0.1 100/200 =1/2=0.5 Y 300/30 = 10 200/100 = 2 ...

Q: The following graph shows the labor market for research assistants in the fictional country of Unive...

A: Case 1: Entire tax is collected from workersThe market equilibrium wage rate is given to be $10 per ...

Q: You are picking an order and come across a box of perfume. What should you do? Please choose all tha...

A: Perfumes are made of various organic molecules (aromatic) and the most abundant in between them is a...

Q: 1. According to Smith, what role did white people play in the capture of slaves? 2. Based on Smith's...

A: A six year old boy was kidnapped to sell in the market for slavery. His name is Venture Smith who is...

Q: Which of the following actions would be most likely to decrease agency costs for the firm? Multiple ...

A: Agency Problems Agency Conflict is any problem that may arise between the owner (the principle) and...

Q: Financial statements from the end-of-period spreadsheetTriton Consulting is a consulting firm owned ...

A: (1). Income Statement Triton Company Income Statement For the Year Ended April 30,20Y3 ...

Q: 1. The numbers 1 through 15 were each written on individual pieces of paper, 1 number per piece. The...

A: Click to see the answer

Q: The stem-and-leaf display shows populations of the 50 regions, in millions of people, according to a...

A: Given stem-and-leaf plot is:

Q: Scenario A. A researcher is interested in understanding how the flexibility of vacation policies at ...

A: According to answering guidelines I can only answer 3 parts of the question.  

Q: Evaluate cosh(72) dz, C the line along the imaginary axis from to 2i. cosh(72) dz

A: Click to see the answer

Q: The cell potential for the standard galvanic cell shown above is +1.56V. If AgNO3(aq)|Ag(s) is repla...

A: Initially, At cathode:   E°AgNO3/Ag=+0.80 V      (reduction)At anode :    E°Zn(NO3)2/Zn=-0.76 V     ...

Q: A.)Briefly describe ONE specific historical similarity between the women’s rights movement of the 18...

A: “The Women's rights movement” was, was active prominently in the U.S. in the 20th century. Women dem...

Q: A nurse measured the blood pressure of each person who visited her clinic. Following is a relative-f...

A: Hi! Thank you for the question, As per the honor code, we are allowed to answer one question at a ti...

Q: When a single salt crystal is added to a cool liquid, large crystals form. Which statement about the...

A: The question is based on the concept of recrystallization. we have to identify the correct statement...

Q: A student collects hydrogen gas over water in a graduated cylinder. If the student measures that the...

A: Given :  The total pressure inside the graduated cylinder = 0.862 atm Also, Inside the cylinder, the...

Q: . Three subject areas where federal statutes have been implemented to protect the personal data of U...

A: According to the question we need to answer - Three subject areas where federal states have been imp...

Q: A remote controlled toy car starts from rest and begins to accelerate in a straight line. The figure...

A: Click to see the answer

Q: Tumbleweed, commonly found in the western United States, is the dried structure of certain plants th...

A: Given that,sample one, n1 =61, p1= x1/n1=0.197sample two, n2 =52, p2= x2/n2=0.385finding a p^ value ...

Q: During an exothermic reaction, H for the reactants was 890 kJ/mol. Which of the following statements...

A: Explanation to the correct answer is given below. 

Q: Kelly Pitney began her consulting business, Kelly Consulting, on April 1, 2016. The accounting cycle...

A: Since we only answer up to 3 sub-parts, we’ll answer the first 3. Please resubmit the question and s...

Q: A solution is prepared by adding 425g of AgNO3 to 0.150L of water at 40.0∘C. The solubility of AgNO3...

A: The solubility of a compound is the dissolution of a solute in the solvent. It is measured in the ma...

Q: Purchase-related transactionsThe debits and credits from four related transactions, (1) through (4),...

A: Credit terms were 1/10, n/30 means that 1% discount will be allowed if payment is made within 10 day...

Q: Trisha has 2 boxes of marbles. She selects a marble from each box 100 times, replacing the marble ba...

A: Given, 2 boxes of marbles To find the probability of selecting red marble from the first box and ora...

Q: MATHEMATICAL CONNECTIONS Point S is between points R and T on RT. a. Use the following information t...

A: Here, point S is between R and T on RT¯. Therefore, RS+ST=RT...(1)  

Q: Mercury poisoning is a debilitating disease that is often fatal. In the human body, mercury reacts w...

A: given amount of mercury in a polluted lake is 0.4 μgHg/mL The lake has a surface area of 100 mi2 and...

Q: Instructions: After interacting on your own with the model above press the "Reset" button. Use the D...

A: Note: Since, you've posted question with multiple sub-parts, we will solve the first the first three...

Q: Calculate the net price factor (as a %) and net price (in $) by using the complement method. Round y...

A: Click to see the answer

Q: MASTERY PROBLEM Lisa Vozniak started her own business, We Do Windows. She offers interior and exteri...

A: Income Statement The preparation of income statement to know the net profitability of the business. ...

Q: QuickBooks Online Accountant allows you to request information from your clients. Which 3 statement...

A: QuickBooks Online Accountant: QuickBooks Online is an accounting tool created for businesses to eval...

Q: The height of 3-year-old boys is approximately normally distributed with mean 34 inches and standard...

A: The normal distribution in the center is generally denser and basically less dense at tails. There a...

Q: Adjusting entries and adjusted trial balances Sears Editing Company is a small editorial services co...

A: Journal entry is a primary entry that records the financial transactions initially.  

Q: When first setting up sales taxes for a client, what information will be prepopulated?   A. Client ...

A: When first setting up sales taxes for a client, the Company address will be prepopulated.

Q: Find the pH of a 0.337 M aqueous solution of hydrofluoric acid (HF), for which K. = 6.8 × 10-4.

A: Consider the dissociation of the given hydrofluoric acid (F) as;      

Q: Jeremy has Parkinson’s disease, a progressive neurodegenerative disease that affects motor skills. I...

A: Psychological and neurological disorders are caused due to malfunctioning of brain. This malfunction...

Q: Plumbing Solutions uses the following accounts.  Transactions: June. 2. Received cash from owner as...

A: Since, direct Ledger posting has been asked and hence instead of recording into Journal Entries dire...

Q: The distribution of weights (rounded to the nearest whole number) of all boxes of a certain cereal i...

A: Given: μ=20σ=2 A. The range of weights includes all of the weights of cereal boxes that are within 1...

Q: what are some ways the history of the Jewish people as slaves, captives, and exiles may have affecte...

A: Religion plays an important role in shaping human development as well as societal norms and regulati...

Q: 4.16 LAB: Varied amount of input data Statistics are often calculated with varying amounts of input ...

A: #include &lt;stdio.h&gt; int main() {     int sum = 0, average, max = 0;     int user_input, counte...