Priority CPU Scheduling Problem

Given 'N' processes with their “burst times”, where the “arrival time” for all processes is ‘0’, and the ‘priority’ of each process, your task is to compute the “waiting time” and the “turn-around time” for each process using the ‘Priority CPU Scheduling’ algorithm.

Processes are scheduled based on priority, with the highest priority being scheduled first. If two processes have the same priority, execute the process with the lower process ID first.

Example:

Input:
T = 1
N = 3
Burst times = [10, 5, 8]
Priorities = [2, 1, 3]
Output:
Waiting Time: [5, 0, 13]
Turn-Around Time: [15, 5, 21]

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 104
  • 1 <= BURST[i], PRIORITY[i] <= 104
Note:

No need to print anything; focus on implementing the function.

AnswerBot
8d

Implement Priority CPU Scheduling algorithm to compute waiting time and turn-around time for processes.

  • Implement a function that takes in burst times, priorities, and number of processes as input

  • Sort ...read more

Help your peers!
Add answer anonymously...
Paytm Front end Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter