Detection algorithm This program prints the inputs and detects whether there is a deadlock or not. If there is no deadlock, it will print a safe pattern of processes.