GATEverse
← GATE CSE 1993

Q15

NATMarks unknown

Consider the recursive algorithm given below: procedure bubblesort (n); var i,j: index; temp : item; begin for i:=1 to n-1 do if A[i] > A[i+1] then begin temp := A[i]; A[i] := A[i+1]; A[i+1] := temp; end; bubblesort (n-1) end Let ana_n be the number of times the ‘if…then…’ statement gets executed when the algorithm is run with value nn. Set up the recurrence relation by defining ana_n in terms of an−1a_{n-1}. Solve for ana_n.

Sign in to save attempts.

Loading…