cs301 gdb solution fall 2022 #cs301gdb2022fall #cs301gdb2022#
1st solution:
Stock is a best option
We developed a hospital application with the help of Stack if someone comes with an emergency, the system will let him go first And Normal patient will give that appointment. According to me stack is a good option for this application and Queue is not good for this case
Some Reason:
• stack helps in managing data in the Last in First out (LIFO) technique.
• Stacks are more secure and reliable as they do not get corrupted easily.
• Stacks are be used for systematic Memory Management,
• Stack allows control over memory allocation and deal location.
• Stack cleans up the objects automatically.
2nd solution:
Solution:
For the given scenario, | choose combination of both stack and queue.
Because:
A stack is a linear data structure in which elements can be
inserted and deleted only ‘from one side of the list, called the top.
A stack follows the LIFO (Last In First Out) principle, i.e., the
element inserted at the last is the first element to come out.
In stacks we maintain only one pointer to access the list, called
the top, which always points to the last element present in the
list.
While, Queues are based on the FIFO principle, i.e., the element
inserted at the first, is the first element to come out of the list.
Insertion and deletion in queues takes place from the opposite
ends of the list. The insertion takes place at the rear of the list
and the deletion takes place from the front of the list.
In queues we maintain two pointers to access the list. The front
pointer always points to the first element inserted in the list and
is still present, and the rear pointer always points to the last
inserted element.
So we need both data structures to fulfill our requirement, that’s why |
prefer combination.
3rd solution:
‘After reading the scenario to develop this application we need both
data structure Stack and Queue. We need their combination to
complete
‘Queue follows the FIFO data structure type. FIFO principle of first
in first out implies that the fist element that inserts into the list will
‘come out fist So from the above scenario if we use a queue data
structure only normal patients can take appointments on the basis of
urival ist come first served. Nojnal patients fist come fist served
is complete with the queue. But in case of emergency patients we
need to get them an appointment immediately no matter if they come
after normal patients they will get an appointment early than normal
patients. This time Queue will not work we need stack for this.
‘Stack follows the lst in first out (LIFO) principle. I implies that the
‘element that is inserted lst come out first. So emergency patients
‘will get appointments immediately.
download file here
0 Comments
Post a Comment