Bird
Raised Fist0

Consider a CPU task scheduler where tasks are represented by characters and each task requires 1 unit of time. If the cooldown period n is 2, what is the minimum time to complete tasks ['B','B','A']?

easy🧾 Trace Q3 of Q15
Greedy Algorithms - Task Scheduler (CPU Cooling)
Consider a CPU task scheduler where tasks are represented by characters and each task requires 1 unit of time. If the cooldown period n is 2, what is the minimum time to complete tasks ['B','B','A']?
A3
B5
C6
D4
Step-by-Step Solution
Solution:
  1. Step 1: Count task frequencies

    Tasks: B=2, A=1
  2. Step 2: Calculate max frequency and idle slots

    Max frequency = 2 (for B), idle slots = (2-1)*2 = 2
  3. Step 3: Fill idle slots with other tasks

    One A fills one idle slot, remaining idle = 1
  4. Step 4: Total time = tasks + idle slots

    Total time = 3 (tasks) + 1 (idle) = 4
  5. Final Answer:

    Option D -> Option D
  6. Quick Check:

    Schedule: B -> A -> idle -> B [OK]
Quick Trick: Calculate idle slots from max frequency tasks [OK]
Common Mistakes:
MISTAKES
  • Ignoring idle time between tasks
  • Assuming tasks can be scheduled back-to-back without cooldown
Trap Explanation:
PITFALL
  • Choosing total tasks count without accounting for cooldown idle time
Interviewer Note:
CONTEXT
  • Tests understanding of cooldown and idle slot calculation
Master "Task Scheduler (CPU Cooling)" in Greedy Algorithms

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Greedy Algorithms Quizzes