Coding Quiz - Task Scheduling
This coding quiz involves implementing a simple task scheduling system using the Queue structure in Python.
Each task is given as a tuple (taskID, processingTime), and you need to implement a scheduling system that processes tasks with shorter processing times first.
For example, if the task list [(1, 3), (2, 2), (3, 5), (4, 1)] is provided, the tasks should be processed in the order [4, 2, 1, 3] based on ascending processing times.
def solution(tasks): # Write your code here return
Constraints
-
The task list can contain up to 10 tasks, and each task's processing time is an integer between 1 and 100.
-
TaskIDs are unique and are represented by consecutive integers starting from 1.
-
If several tasks have the same processing time, process them in the original order provided.
Input/Output Examples
-
Input:
[(1, 3), (2, 2), (3, 5), (4, 1)] -
Output:
[4, 2, 1, 3]
-
Input:
[(1, 4), (2, 1), (3, 3)] -
Output:
[2, 3, 1]
Lessons in this chapter · Review and Deepen Understanding of Python Data Structures
- 1. Review of Key Data Structures
- 2. Multiple-choice quiz
- 3. Fill-in-the-blank quiz
- 4. Coding Quiz - Reverse Words
- 5. Coding Quiz - Task Scheduling
- 6. Coding Quiz - Check for Value Existence
- 7. Coding Quiz - Find the First Non-repeating Character
- 8. What is a Tree?
- 9. Tree Implementation Techniques
- 10. Multiple-choice quiz
- 11. Coding Quiz - Find Minimum Odd Value
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help