Please explain the test case
Please explain the problem statement
@sharad1103
Calling Order : 5 4 2 3 1
Ideal Order : 5 2 1 4 3
Iteration 1 :
Calling Order : 5 4 2 3 1
Ideal Order : 5 2 1 4 3
Since both the processes are same (5) , they get executed .
Time = 1
Iteration 2 :
Calling Order : 4 2 3 1
Ideal Order : 2 1 4 3
Since both the processes are same different , we move 4 back to the end and rotate the array .
Time = 2
New Calling Order : 2 3 1 4
Iteration 3 :
Calling Order : 2 3 1 4
Ideal Order : 2 1 4 3
Since both the processes are same (2) , they get executed .
Time = 3
Iteration 4 :
Calling Order : 3 1 4
Ideal Order :1 4 3
3 goes at the end since 1 != 3.
Time = 4
New Calling Order : 1 4 3
Iteration 5 :
Calling Order : 1 4 3
Ideal Order :1 4 3
Process 1 gets executed
Time = 5
Iteration 6 :
Calling Order : 4 3
Ideal Order :4 3
Process 4 gets executed
Time = 6
Iteration 7 :
Calling Order : 3
Ideal Order :3
Process 3 gets executed
Time = 7
Final Output : 7
Hope this helps