Develop a pseudo-code that reads the lists j, p and d as inputs and prints a lis
ID: 3750621 • Letter: D
Question
Develop a pseudo-code that reads the lists j, p and d as inputs and prints a list with the indexes of the jobs that are completed late if the jobs are processed in non-decreasing order of their index (i.e. 0 1 2 …)
PART 1: PSEUDO-CODE Let J be a set of jobs that need to be processed on a single machine. Let p, and d be the processing time and due date of job j in J. Assume the following inputs: jobs (index) é processing times p [10, 3, 4, 8, 10, 6] d [15, 6, 9, 23, 20, 30 due dates Problem 1-20 pointsExplanation / Answer
ANS:
Pseudo Code -:
Start
Create an empty list named lateprocess
intitilize variable time to 0
initilize varible i to 0
while(i< lengthof( j ) ) do
set value of time to (time+p[ i ])
if (time > d[ i ]) then
add j[ i ] in the list lateprocess
set value of i to (i+1)
Print the elements of list lateprocess
End
Explanation :-
we keep a variable time to track the current time.
we add processing time of job one by one
if time is greater then the due date of job . It means that the job is late. so we add it in the list of lateprocess.
Finally we print the elements of the list.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.