Indicate whether a stack, or a queue, or none of them be a suitable data structu
ID: 3121846 • Letter: I
Question
Indicate whether a stack, or a queue, or none of them be a suitable data structure for each of the following application. A bank simulation of its teller operation to see how waiting times would be affected by adding another teller. An address book to be maintained A word processor to have a PF key that causes the preceding command to be redisplayed. Every time the user presses the PF key, the program shows the command that preceded the one currently displayed. A program to keep track of patients as they check into a medical clinic, assigning patients to doctors on first come, first serve basis. A data structure used to track of the return addresses nested functions while a program is running. Use the linked list picture below Write as few statements as possible to do each of the following Delete the node containing 45. Create a new node that contains 48 and insert the new node right after the node containing 15.Explanation / Answer
Answer 4.
(1) Queue
In this it is a queue as the first user is served as first preference and the added user have to wait for its chance.
(2) None of them.
It does not fit either stack or queue. In a address book entries are added as when required but it is not fetched in order rather in a random way as when it required thus not meeting any of the criteria of stack and queue.
(3) Stack
In this scenerio, stack comes into play. As and when the PF key is pressed the command that preceded the one currently displayed i.e the command entered last is poped out to display as soon as PF key is pressed statisfy the condition of LIFO of stack.
(4) Queue
In this the question says the answer by own, "first come, first serve basis" i.e the one coming first gets the chance to check up in medical clinic, which shows the property of FIFO.
(5) Stack
While the program is running it is returning addresss one by one in a sequence and it can be tracked by storing them in a stack.