c - How to compute the output? -
How to calculate the output for recursive functions? I know that Rickson invokes a stack, but some qualification is confusing while solving the question.
Looking at the following code snippet:
#include & lt; Stdio.h & gt; Zero fun (int a) {if (a> 0) {fun (a); Printf ("% d", A); Fun (- a); Printf ("% d", A); } Return; } Int main (zero) {int num = 5; Fun (number); Return 0; }
This is not a house work, but I am unable to resolve such a question in the examination situation. (Theoretical Examination Without Compiler)
What is the standard way to resolve such questions? Please explain with a small example. Any pointer or some web link in the right direction will be welcomed.
Take a pen and paper; Attract the functions of the function with parameters - you will have a kind of binary tree track the execution and write all the relevant data on the page. This will also help you understand the functionality.
The branches included in recurring invoices (especially those of this type of binary) are very logical and intuitive when you drag it on a paper, and this way I was taught back to school - and things like that Imo, a good way to understand, at least when everything is not easy at the beginning.
Example:
Fun [5] / \ Fun [4] Funny [3] / \ | Funny [3] Funny [2] Funny [2] Funny [1]
I pulled the calling tree, in the same way you can pull it on paper. It is clearly going on for you, you should help. And in exactly the way I handled such things back in the day, so believe me - it works :)
Comments
Post a Comment