What will be the base case for the code of recursive insertion sort ?

What will be the base case for the code of recursive insertion sort ?
A.
if(n < 1)
return;
B.
if(n == 0)
return;
C.
if(n <= 1)
return;
D.
If(n == 2)
return;
 
Answer: c
Explanation: The most appropriate condition for the base case of recursive insertion sort is when n is less than or equal 1 then return. It is because we know that an array with only 1 element is always sorted.
 

Tìm kiếm

Back
Top