In: Computer Science
RecursiveFunction(n) // n is an integer {
if (n > 0){
PrintOut(n % 2);
RecursiveFunction(n / 3);
PrintOut(n % 3);
}
}
What is the output of this RecursiveFunction Pseudocode algorithm if it is initially called with 10 for n? Explain how you arrived at that answer; by writing call stack for the execution of his function at each step. What is the Big O running time of the RecursiveFunction described above? Explain your answer.
RecursiveFunction(10)
=> print(10 % 2) => print 0
=> RecursiveFunction(3)
=> print(3 % 2)
=> print 1
=>
RecursiveFunction(1)
=>
print(1 % 2) => print 1
=>
RecursiveFunction(0)
=>
Nothing is done here.
=>
print(1 % 3) => print 1
=> print(3 % 3)
=> print 0
=> print(10 % 3) => print 1
Output: 0, 1, 1, 1, 0, 1
**************************************************
I have tried to answer your question to best of my efforts.
However, if you still face any issues in the answer, please let me
know via the comment section. Your feedback will imporve as well as
encourage me to keep up the good work.
If i was able to help you, then please provide me an
upvote(thumbs up). Thanks!