algorithm analysis ( ( ( ( ( ( sum fori ++ ++sumsum fori ++ forj ++ ++sumsum fori ++ forj ++ ++sumsum fori ++ forj ++ ++sumsum fori ++ forj ++ fork ++ ++sumsum fori ++ forj ++ ifj = fork ++ ++sumsuppose you need to generate random permutation of the first integers for example{ and { are legal permutationsbut { is notbecause one number ( is duplicated and another ( is missing this routine is often used in simulation of algorithms we assume the existence of random number generatorrwith method randint( , )that generates integers between and with equal probability here are three algorithms fill the array from [ to [ - as followsto fill [ ]generate random numbers until you get one that is not already in [ ] [ ] [ - same as algorithm ( )but keep an extra array called the used array when random numberranis first put in the array aset used[rantrue this means that when filling [iwith random numberyou can test in one step to see whether the random number has been usedinstead of the (possiblyi steps in the first algorithm fill the array such that [ii+ then fori ++ swapai ]arandint ) prove that all three algorithms generate only legal permutations and that all permutations are equally likely