I'm trying to analysis the complexity of this algorithm, I predicted that it's t(n) = n*t(n) + 1 and solve the t(n) via master theorem which is n^logn. however, I'm not sure, and stuck with it.
Algorithm CheckPath(m[0..n-1][0..n-1],v1,v2)
if v1==v2
return 0
cost = 0
for i = 0 to n-1
if m[v1]m[v2]!=0 //any path exits
cost2 = m[v1]m[v2]+checkpath(m,i,v2)
if cost2<cost OR cost==0
cost = cost2
return cost
EDIT: I corrected the costtmp as cost 2, it does not goes to an infinite loop while I check if v1==v2 return 0
n*t(n) + 1is undefined (the recursive formula stays at n) , probably meantn*t(n-1), which is moreO(n!)