a company wishes to modify the technique by which tasks in the processing queue are executed. there are N process with queue IDs from 0to N-1. each of these tasks has its own execution time. the company wishes to implement a new algorithm for processing tasks.for this purpose they have identified a value K. by the new algorithm the processor will first process the task that has the Kth shortest execution time.
write an algorithm to find the Kth shortest execution time
Answers
Technical Arts is the traditional RSTA Exploratory course and students rotate through all technical areas. It is a semester-long grand tour of: Automotive Technology. Biotech. ... Information Technology.
Answer:
A company wishes to modify the technique by which tasks in the processing queue are executed. There are N processes with unique IDs from 0 to N-1. Each of these tasks has its own execution time. The company wishes to implement a new algorithm for processing tasks. For this purpose they have identified a value K. By the new algorithm, the processor will first process the task that has the Kth shortest execution time.
Write an algorithm to find the Kth shortest execution time.
Input Format
The first line of the input consists of two space-separated integers — num Tasks and value K, representing the number of tasks (N) and the value K, which is used as reference respectively.
The second line consists of N space-separated integers — executionTime1, execution Time 2,. Execution Time N representing the execution times of the tasks.
Output Format
Print an integer representing the Kth shortest execution time.
Constraints
0 ≤ valueK < numTasks ≤ 106
0 ≤ executiontimei≤106
0 ≤ I < numTasks