Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Toll Booth Simulation Using Queues: A Data Structures Assignment, Assignments of Data Structures and Algorithms

Material Type: Assignment; Class: DATA STRUCTURES I; Subject: Computer Science; University: Wentworth Institute of Technology; Term: Spring 2006;

Typology: Assignments

Pre 2010

Uploaded on 08/17/2009

koofers-user-tdw
koofers-user-tdw 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP380 Section 71 - Data Structures I - Spring, 2006
Homework 11 – Toll Booth Simulation (Queues)
Instructor: Bob Goldstein (617) 912-2512
bobg@vision.eri.harvard.edu
http://webpages.charter.net/tlgcreations/Courses/index.html
http://goldstein.eri.harvard.edu/courses/index.html
http://myweb.wit.edu/goldsteinr/Courses/index.html
Due Date: April 27, 2006 (two weeks)
Hand In: Printout of program code and dialogue of how it runs.
Purpose: Use queues to simulate a toll booth plaza
1. You will write a program similar to the “Bank Queue” simulation we did in class, but instead of
banks, you will simulate a toll booth plaza.
2. Your simulation will be designed to answer the question “When is the appropriate time to change
a “cash” toll booth lane to a “fast lane” toll booth lane.
3. This particular plaza has a total of four toll booths. There is initially a single “fast lane” toll booth
and three “cash” toll booths. HOWEVER, write your program so that at the beginning of the run,
you can designate each toll booth to be either type.
4. Set up the following constants at the beginning of your simulation, that can be changed each time
the simulation will run:
a. NUM_CARS – the number of cars generated for the duration of the simulation
b. TRANS_TIME_FOR_CASH – transaction time for a cash car to go through
c. TRANS_TIME_FOR_FAST – transaction time for a fast-lane car
d. CASH_TO_FAST_RATIO – ratio of cash cars to fast-lane cars.
e. CAR_GENERATION_FREQUENCY – how often a car will be “generated”
5. When a car is generated, it will be generated either as a cash car or a “fast-lane” car. A “fast-lane”
car can use only the fast-lane booths, and a cash car can only use the fast-lane booths.
6. Run the simulation with various CASH_TO_FAST_RATIOs, and plot the length of the fast lane
queue at the end of the run versus this ratio. When the length of the fast-lane toll booth becomes
double that of the average of the cash toll booths, that is when you need to change a cash to a fast-
lane.
7. Run the simulation one more time, making the change so that there are two toll booths of each
type, and see how the lengths of the queues at the end of the run is changed by making this
alteration.
Extra Credit:
1. Use your simulation to answer the question “do we need to increase the number of toll
booths?”.
2. Alter the rules of use so that a “fast-lane” car can use a “cash” booth if the queue size is
too long at the “fast-lane” booth.
/app/work/qkdcdl-374896-2765016-homework11-doc.doc 1 12/4/2020 12/4/2020

Partial preview of the text

Download Toll Booth Simulation Using Queues: A Data Structures Assignment and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP380 Section 71 - Data Structures I - Spring, 2006

Homework 11 – Toll Booth Simulation (Queues)

Instructor: Bob Goldstein (617) 912- bobg@vision.eri.harvard.edu http://webpages.charter.net/tlgcreations/Courses/index.html http://goldstein.eri.harvard.edu/courses/index.html http://myweb.wit.edu/goldsteinr/Courses/index.html Due Date: April 27, 2006 (two weeks) Hand In: Printout of program code and dialogue of how it runs. Purpose: Use queues to simulate a toll booth plaza

  1. You will write a program similar to the “Bank Queue” simulation we did in class, but instead of banks, you will simulate a toll booth plaza.
  2. Your simulation will be designed to answer the question “When is the appropriate time to change a “cash” toll booth lane to a “fast lane” toll booth lane.
  3. This particular plaza has a total of four toll booths. There is initially a single “fast lane” toll booth and three “cash” toll booths. HOWEVER, write your program so that at the beginning of the run, you can designate each toll booth to be either type.
  4. Set up the following constants at the beginning of your simulation, that can be changed each time the simulation will run: a. NUM_CARS – the number of cars generated for the duration of the simulation b. TRANS_TIME_FOR_CASH – transaction time for a cash car to go through c. TRANS_TIME_FOR_FAST – transaction time for a fast-lane car d. CASH_TO_FAST_RATIO – ratio of cash cars to fast-lane cars. e. CAR_GENERATION_FREQUENCY – how often a car will be “generated”
  5. When a car is generated, it will be generated either as a cash car or a “fast-lane” car. A “fast-lane” car can use only the fast-lane booths, and a cash car can only use the fast-lane booths.
  6. Run the simulation with various CASH_TO_FAST_RATIOs, and plot the length of the fast lane queue at the end of the run versus this ratio. When the length of the fast-lane toll booth becomes double that of the average of the cash toll booths, that is when you need to change a cash to a fast- lane.
  7. Run the simulation one more time, making the change so that there are two toll booths of each type, and see how the lengths of the queues at the end of the run is changed by making this alteration. Extra Credit:
  8. Use your simulation to answer the question “do we need to increase the number of toll booths?”.
  9. Alter the rules of use so that a “fast-lane” car can use a “cash” booth if the queue size is too long at the “fast-lane” booth. /app/work/qkdcdl-374896-2765016-homework11-doc.doc 1 12/4/2020 12/4/