Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6051199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:47:50+00:00 2026-05-23T07:47:50+00:00

How can I analyze a recursive source codes by hand? For example, I have

  • 0

How can I analyze a recursive source codes by hand?

For example, I have devised a technique for analyzing iterative source code by hand like this:

int fact(int n) 
{ 
 int f = 0; 
 int i = 0; 
 if (n<=1)  
 {  
  return 1; 
 } 

 f = 1; 
 i = 2; 
 for (i=2; i<=n ; i++) 
 { 
  f *= i; 
 } 

 return f; 
}

---------------------------
  i         f       new-f
---------------------------
---------------------------
---------------------------

For each ‘i’ I can analyze and calculate the values of old-f and new-f by hand and fill up the table to see if the routine is working correctly.

But how can I analyze recursive routines by hand?

int fact(int number) {
    int temp;

    if(number <= 1) return 1;

    temp = number * fact(number - 1);
    return temp;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:47:51+00:00Added an answer on May 23, 2026 at 7:47 am

    Since recursion stores values on the stack you need to analyze it 2-way

    1st pass is: do the recursion until the termination condition is reached.

    2nd pass: collect the values until the stack is empty.

    1st down  2nd up
    ---------------------------------
    n = 6     tmp = 6 * 120 = 720 <- result
    n = 5     tmp = 5 * 24 = 120
    n = 4     tmp = 4 * 6 = 24
    n = 3     tmp = 3 * 2 = 6
    n = 2     tmp = 2 * 1 = 2
    n = 1     end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I count operations in C++? I'd like to analyze code in a
I have a program that will analyzes source code. It can recursively go through
Can i get the source code for a WAMP stack installer somewhere? Any help
How can I code in Android such that my app can analyze an incoming
Hi My app had visitors and I like to analyze the log file. Can
I use pstack to analyze core dump files in Solaris How else can I
Is there a tool that can analyse my .NET code (C# and VB.NET )
Can anyone tell me how I can display a status message like 12 seconds
Recently I have been studying recursion; how to write it, analyze it, etc. I
I have a some code that gets passed a class derived from a certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.