what and how is the time complexity of the pemutations algorithm.Please explain it clearly.I m confused
Time Complexity(Permutations)
Hey @dare_devil_007
There are n! permutations of a string so we are generating n! perms and it takes O(n) to print all perms
Hence complexity is n*n!
If we see recursive wise then in first call i=0 then we are running loop n times
then in next call i=1 and we are running loop n-1 times and so on
So n*n-1*n-2 *… =n! And when i=n then we print the perm so we will print n! times beacuse that many perms are there
1 Like