Question: Give practice implementing a queue via a linked list. Give practice designing a functioning program without all function prototypes being given. Give practice following and
Give practice implementing a queue via a linked list.
Give practice designing a functioning program without all function prototypes being given.
Give practice following and implementing rules in a simulation.
Background Story
Our theater always shows block buster movies and there is constantly high demand for tickets. Tickets
need to be purchased in advance from the ticketing center. The ticketing center has queues numbered
from to and some booths max to handle those queues. Due to a recent hurricane in the other
part of the state, many ticketing employees are on leave to take care family at their home cities affected
by the hurricane. So due to the shortage of employees we are operating only b number of booths b
operated by b number of employees. The booths are numbered from to b All the customers must
arrive and stand in one of the queues before getting redirected to one of the booths we assume this
redirection takes no time.
Upon arrival, a customer enters the name a single string with max length with all upper case letters
and number of tickets nt nt in the kiosk. The time of arrival t t is automatically
recorded and is unique for each customer. After receiving this data, the system extracts the first letter of
the name and gets its position p p in the alphabet. For example, if the name is ADAM, then p
for ADAM is A B Z Then the system automatically assigns a queue number q
based on the following strategy:
The queue number q of a customer is p if p
If p is zero, then the customer is assigned to the first nonempty queue with the least number
of customers across all of the queues. If the least number is same for multiple queues, then the
customer is assigned the first queue based on the queue number out of those queues. If the very
first customer is in this category, assign them to the first queue. We define the size of a queue to
be the total number of people that have previously been in that queue at any point.
Processing the customers
For the purposes of this problem, we assume that before the employees start processing customers, it is
known in advance which of the queues will be nonempty at some point in time. Let the number of
queues that receive at least customer at some point in time equal k
Due to the shortage of employees, for all of the cases your program will be run, k b
The k queues will be split amongst the b booths as follows:
Each booth will receive customers from at least
queues, where represents the greatest integer
less than or equal to xThis is the technical way to define integer division for positive integers,
mathematically. It's called the floor function.
The first kb booths will receive one more queue. The queues will be assigned in numerical order, with
the smallest queues being assigned to booth the next smallest queues being assigned to booth and
so forth.
Let's consider a couple examples.
Let the nonempty queues be and and let there be booths.
Since
each booth will have at least queue assigned to it and the first booths will
receive customers from two queues.
Thus, for this example, all customers from queues and will go to booth all customers from queues
and will go to booth all customers from queue will go to booth and all customers from queue
will go to booth
For the second example, let the nonempty queues be and and let there be
booths.
and Thus, the queues will be assigned to booths as follows:
Booth : Queues
Booth : Queues
Booth : Queues
The booths start processing customers at time t As soon as the first customer arrives at a booth, the
employee at that booth starts processing her order. The processing time in seconds of a customer is
calculated by number of tickets For example, if a customer buys tickets, then it would take
seconds to process her transaction.
If a customer arrives in the queue before her assigned booth is ready, she will continue to wait in her
queue until that booth is ready to call her up to process her order.
The Problem
Write a program that reads in information about customers: customer name, number of tickets and time
of arrival, and uses this information to determine which booth each customer will buy tickets from, and
at what time they will complete their transaction.
Input
The first line will contain positive integers, n n the number of customers purchasing
tickets and b b the number booths operating on that day.
The following n lines will have information about each customer. These n lines will be sorted from
earliest arrival time to latest arrival time. Each of these lines will start with the name of the customer, a
single string of to uppercase letters, followed by a positive integer,
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
