Implement the detection algorithm.
Input: n m; Available; n rows of Allocation; n rows of Request (current outstanding requests).
- Processes whose allocation is all zeros are finished from the start (they do not appear in the completion list).
- Repeat passes over P0…Pn−1: take, in index order, every unfinished process whose Request ≤ Work, and add its Allocation to Work.
Print Can complete (in order): P0 P2 P3 P4 P1 (or none), then No deadlock or DEADLOCK: P1 P2 P3 P4 (the unfinished processes, in index order).