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

Hi can someone please help me to answer this question? The answer could be one o

ID: 3811376 • Letter: H

Question

Hi can someone please help me to answer this question? The answer could be one or more than one. Anyone has any idea, of which one is/are the right answer(s)? This is a C programming class..

Which of the following are examples of head recursion? O int sum (int in, count) f if (count 0) return 0 int retval ln. retval suma (in sizeof (int) co 1) return ret val; int sum (int in, count) f if (count 0) return 0 sum (in sizeof (int) 1) return Count ln. O int suma (int* in, count) f if (count 0 return *in sum (in sizeof (int) count 1) O int sum (int in, count) f if (count 0) return 0 int retval sum (in sizeof (int) Count 1) retval ln. return ret val;

Explanation / Answer

Defination of Head recursion :-

You make a recursive call first then do the calculation once the call is back.

-----------------------------------------------------

So let a option:-

retval+= sum(in+sizeof(int)),count-1) ;

return retval;

we call sum(in+sizeof(int)),count-1) this recursive function after call back we add retval value to the result of this recursive function and then return this return value.

so we have to perform some compution after call back of recursive function so this is head recursion.

-----------------------------------------------------------------------------------------------------------------------------------------

All options are head recursion because for each recursive call we perform some computaion then return final value so this is head recursion

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote