Redirected
recategorized by
4,558 views
7 votes
7 votes

Consider a system which have $‘n’$ number of processes and $‘m’$ number of resource types. The time complexity of the safety algorithm, which checks whether a system is in safe state or not, is of the order of :

  1. $O(mn)$ 
  2. $O(m^{2}n^{2})$
  3. $O(m^{2}n)$
  4. $O(mn^{2})$
recategorized by

6 Answers

Best answer
7 votes
7 votes

The below part introduces (n*m) time complexity

for I = 1 to N do // *n times
      if ((not FINISH[i]) and
         NEEDi <= WORK) then // *m times, if it's an array search

but it is also nested in a repeat loop. If that loop can run, in worst case, n times, then the procedure has O(n*n*m) time complexity.

WORK = WORK + ALLOCATION_i; // also O(m) operation, vectors addition

So, the code that executes in the for loop has O(m+m) time complexity.
Of course, O(m+m) = O(m) and the final complexity is O(n*n*m).

selected by
2 votes
2 votes

In  system of ‘n′ number of processes and ‘m′ number of resource types, complexity of Bankers algorithm will be O( m*n 2 )

NB:

Bankers algorithm cannot allocate resources to multiple processes simultaneously. Resource allocation graph method has complexity of O( n 2) only

0 votes
0 votes
For n processes and m resources, time complexity of Banker's Algorithm is O(n*n*m).

D is correct.
Answer:

Related questions