Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program based on this algorithm. The Algorithm We can use a queue to simulate the flow of customers through a check-out line in a

C++ program based on this algorithm.

image text in transcribed

The Algorithm

We can use a queue to simulate the flow of customers through a check-out line in a store. In this simulation we will have the following details:

1.one check-out line

2.the expected service time for each customer is one minute (However, they may have to wait in line before being serviced)

3.between zero and two customers join the line every minute

We can simulate the flow of customers through the line during a time period n minutes long using the following algorithm:

Initialize the queue to empty. for ( minute = 0 ; minute k between 0 and 3. If k is 1, then add one customer to the line. If k is 2, then add two customers to the line. Otherwise (if k is 0 or 3), do not add any customers to the line. } 

In addition, the algorithm will keep track of the following:

1.the total number of customers served

2.the combined total wait time of all customers

3.the maximum length of time any of these customers spent waiting in line

reference :

http://www.cs.uregina.ca/Links/class-info/210/Queue/

Given a time of 5 minutes, the following demonstrates the operations on the queue: queuequeue operations sempty? corresponding diagram 0yes no dequeue (empty queue) 1enqueue(o) 0 no 2 enqueue(1) enqueue(1) no 2 |enqueue(2) enqueue(2) 2 no 2 2 1 enqueue(3) no dequeue 0 no enqueue (k-o) Notice that the data in the node is the time (minute) that the "customer" joined the line. This data is used to compute the wait time of a customer. Given a time of 5 minutes, the following demonstrates the operations on the queue: queuequeue operations sempty? corresponding diagram 0yes no dequeue (empty queue) 1enqueue(o) 0 no 2 enqueue(1) enqueue(1) no 2 |enqueue(2) enqueue(2) 2 no 2 2 1 enqueue(3) no dequeue 0 no enqueue (k-o) Notice that the data in the node is the time (minute) that the "customer" joined the line. This data is used to compute the wait time of a customer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books