Answer to Question #203030 in Java | JSP | JSF for Emmanuel Saah Kpon

Question #203030

B. Identify a real-world scenario for the below task:6 A task where the next one to work on is always the one that has been waiting the longest. i. For the above task, explain your choice of an appropriate data structure for such a task. [3 marks] ii. Provide the corresponding algorithm for solving such a problem based on the data structure you chose above. You can represent each step diagrammatically. [5 marks


1
Expert's answer
2021-06-04T07:14:00-0400
  1. The appropriate data structure for the task is a QUEUE. The queue works on the principle of First In First Out (FIFO). The task that has taken the longest time is the one to be processed. Therefore, a queue is the correct and appropriate data structure for this scenario. For example, in banks queue is used to serve the person that has waited for the longest time.
  2. The algorithm that will best overcome the problem of waiting in queue is the round-robin algorithm. The round-robin algorithm works by giving each task, a time slice called a quantum. A task can be serving an employee in a bank where there is time allocated for serving a customer. The round-robin algorithm always works in favor of shorter tasks because they use the first quantum allocated to them. The shorter tasks will leave the queue, giving more time to longer jobs that require more time. Therefore, more tasks will not wait for a longer time, hence overcoming the problem of waiting.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS