Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please give explanation as well Question 6 Consider the following funtion: int r

ID: 3812075 • Letter: P

Question

Please give explanation as well

Question 6 Consider the following funtion: int recursive int n) The assembly code equivalent of the above function is recursive push %ebp mov %esp,%ebp push %ebx sub sex 14,%esp cmpl $0x1,0x8(%ebp) je L1 cmpl $0x2,0x8(%ebp) jne L2 L1 mov 0x8 (%ebp),%eax jmp 13 L2 mov 0x8 (%ebp),%eax sub $0x1, %eax mov %eax, (%esp) call recursive mov %eax,%ebx mov 0x83 (%ebp),%eax sub $0x2,%eax mov %eax, (%esp) call recursive imul %ebx,%eax L3 add $0x14,%esp pop %ebx pop %ebp ret What would be the values returned for the code below? int ret val 1 recursive (1); int ret val 2 recursive (2); O return val 1 is 2 and return val 2 is 1 return val 1 is 1 and return val 2 is 1 return val 1 is 1 and return val 2 is 2 O return va 1 is 2 and return val 2 is 2 O return val 1 is 3 and return val 2 is 3 1 pts

Explanation / Answer

what would be the values returned for the code below?
int ret_val_1 = recursive(1);
int ret_val_2 = recursive(2);

Solution: return_val_1 is 2 and return_val_2 is 1

The function called by itself is called as recursive functionsince the definition contains a call to itself.Each recursive definition requires base cases in order to prevent infinite recursion.