Lecture

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.


Write Code
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]

Lecture

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help