Examveda

What is the name given to the algorithm depicted in the pseudo code below?
procedure generate(n : integer, Arr : array):
    if n = 1 then
          output(Arr)
    else
        for i = 0; i <= n - 2; i ++ do
            generate(n - 1, Arr)
            if n is even then
                swap(Arr[i], Arr[n-1])
            else
                swap(Arr[0], Arr[n-1])
            end if
        end for
        generate(n - 1, Arr )
    end if

A. bubble sort

B. heap sort

C. heap's algorithm

D. prim's algorithm

Answer: Option C


This Question Belongs to Data Structure >> Miscellaneous On Data Structures

Join The Discussion

Related Questions on Miscellaneous on Data Structures