diffrence in non recusion and recursion


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting diffrence in non recusion and recursion
# 1  
Old 12-06-2007
diffrence in non recusion and recursion

Hi,


If i have given to write a prog for factorial in C using recursion and without
recursion which one is better in what condition and why ?



thanks
# 2  
Old 12-06-2007
Quote:
Originally Posted by useless79
Hi,


If i have given to write a prog for factorial in C using recursion and without
recursion which one is better in what condition and why ?



thanks
The recursion one is really easy to code but will take a little long to produce result (and limited by the size of your stack memory ?) than without a recursion ... at list on a P150mhz Smilie
# 3  
Old 12-06-2007
The usual idiom is that if the algorithm potentially requires many levels of recursion (say 100), then avoid recursion.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Diffrence between stripping and mirroring

Hi All, What is the difference between stripping and mirroring? Thanks, Rafi. (3 Replies)
Discussion started by: rafidba.alvi
3 Replies

2. Shell Programming and Scripting

diffrence in executing a shell script

hi Could some one let me know what is the diffrence in executing a shell script as below $sh script.sh (this is executed in a subshell) $./script.sh(this is executed in the current shell) $script.sh(this is executed in a subshell) where script.sh is the name of the shell script. ... (1 Reply)
Discussion started by: sowjanya
1 Replies

3. Shell Programming and Scripting

time diffrence between two lines in a log file

Hi Experts, I am writing a shell/Perl script tp get a time diffrence of two lines in a log file. I am pasting a snippet of my log file, how it look likes. Sun Apr 26 02:11:03.162 2009 Greenwich Standard Time LOW: pid 488 tid 2072: 0: 251360: calling ARRF_LIB_Evaluate. Sun Apr 26... (24 Replies)
Discussion started by: namishtiwari
24 Replies

4. Programming

Recursion

I want to halt a tail recursive function after certain validation. I want to come out of entire recursion without unwinding phase. How can i achieve that . The coding is done in C language. (5 Replies)
Discussion started by: joshighanshyam
5 Replies

5. Shell Programming and Scripting

diffrence between .cshrc .login .profile

Hi.. i was just looking to know the diffrence between this three terms 1) .cshrc 2) .login 3) .profle but iam failed to findout the exact diffrent Please can any one share the diffrence between this regards Syed (1 Reply)
Discussion started by: smuqtaderali
1 Replies

6. UNIX and Linux Applications

diffrence between .cshrc .login .profile

Dear experts ... Please any one can describe the diffrence between this three 1) . cshrc 2) .profile 3) .login cheers syed (1 Reply)
Discussion started by: smuqtaderali
1 Replies

7. UNIX for Dummies Questions & Answers

Can any how we can find the time diffrence...?

Hi, I am trying to caluate the time elasped by the job to run.For that i have used the following command: I have one file which contains the following more start.txt 991 STARTED Fri Aug 10 14:04:20 2007 Starting Job JOB_NAME. (...) 1036 STARTED Fri Aug 10 14:04:31 2007 ... (1 Reply)
Discussion started by: Amey Joshi
1 Replies

8. Shell Programming and Scripting

Help Help Help in recursion

Hello every body. I am trying to find the factorial using the following code. But it is giving the syntax error. I tried very much but in vain. Thanks in advance for helping me factorial() { if then y=`expr $1 - 1` x=$(( $1 \* factorial $y ))... (6 Replies)
Discussion started by: murtaza
6 Replies

9. Shell Programming and Scripting

recursion

I'm using the UNIX csh and i wish to use recursion to nav my way up (or down as it is) a given folder. My little test script is called "r" and takes a folder as argv (or $1) #!/bin/tcsh -f set allFiles = `ls -A $argv` cd $argv while ($#allFiles) if (-d... (1 Reply)
Discussion started by: gsjf
1 Replies

10. UNIX for Dummies Questions & Answers

recusion through file system

is there anyway the following command can be executed recursively throught the whole file system. The command searches for a specific file name and shows a count of how many files there are with that particular name ls -a | grep -c (1 Reply)
Discussion started by: provo
1 Replies
Login or Register to Ask a Question