Consider a schedule with 4 transactions with 1, 2, 3, and 4 operations respectively. Calculate the possible
number of
a) Serial schedules
b) Non serial schedules
Source Code
def factorial(n):
fact=1
if(n==1):
return n;
else:
for i in range(1,n+1):
fact*=i
return fact
sum1=1+2+3+4
total_num_schedule=factorial(sum1)/(factorial(1)+factorial(2)+factorial(3)+factorial(4))
print("Total number of schedules: ",total_num_schedule)
num_serial_schedule=factorial(4)
print("Number of serial schedule: ",num_serial_schedule)
num_non_serial_schedule=total_num_schedule- num_serial_schedule
print("Number of serial schedule: ",num_non_serial_schedule)
Output
Comments
Leave a comment