The deadlock detection algo investigates every possible allocation sequences for the processes that remain to be completed.
The total allocated resources to all processes of resource type B doesn't match with that mentioned in the question. If we ignore the statement and take the tables as the right one then the solution is as follows:
Process P0 and P2 have been allocated all its resources and hence will run till completion. They will give up the resources they were allocated. This is the state:
Available: A = 3 B = 1 C = 3
Processes left: P1 P3 P4
Process P1 requires: A = 2 B = 0 C = 2
We can fulfill its request. It will be allocated all the resources and will run till completion. Then it will give up all the resources. Now this will be the state:
Available: A = 5 B = 1 C = 3
Processes left: P3 P4
Similarly, next process P3 will be executed first and then P4.
Ans: option 4.