\\ 2. indicate whether a queue would be a suitable data structure to use in each
ID: 3600955 • Letter: #
Question
2. indicate whether a queue would be a suitable data structure to use in each of the following applications.
a. an ailing company wants to evaluate employee records so that it can lay off some workers on the basis of service time(the most recently hired employees are laid off first)
b. a program is to keep track of patients as they check into a clinic, assigning them to doctors on a first come first served basis.
c. a program to solove a maze is to backtrack to an earlier position ) the last place where a choice was made) when a dead end position is reached.
d. an inventory of parts is to be processed by part number.
e. an operating system is to process requests for computer resources by allocating the resources in the order in which they are requested.
f. a grocery chain wants to run a simulation to see how average customer wiat time would be affected by changing the number of checkout lines in its stores.
g. a dictionary of words used by a spelling checker is to be initialized.
h. customers are to take numbers at a bakery and be served in order when their number comes up.
I. Gamblers take numbers in the lottery and win if their numbers are picked.
Explanation / Answer
Here are the answers :
a. No
Reason : Queue is First in first out but here we need last in first out ( as most recent employees are layed off first)
b. Yes
Reason : Here first in first out is required (first patient gets the doctor first)
c. No
Reason : To backtrack we move to the last added position thus we need last in first out not first in first out
d. No
Reason : Here order of insertion doesn't matter , sorted list of parts is required which is not supported by queue
e. Yes
Reason : Here resources are allocated on first come first serve basis so queue can be used
f. Yes
Reason : In checkout lines , first customer is served first so queues can be used
g.Yes
Reason : Dictionary can be initialized on first come first serve basis
h. No
Reason : Here orders comes not on first come first basis but on first cooked first deliver basis. So the number can come randomly , thus queue can't be used
i. No
Reason : Here numbers are picked randomly
**If you have any query , please feel free to comment with details.
**Happy learning :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.