ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2254)
 C++ interview questions  C++ Interview Questions (1111)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (646)
Question
what are the advantage and disadvantage of recursion
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
Recursion will be useful when same kind of job has to be
continued for a finite no input or time.

Eg: calculating series, finding factorial etc..

Disadvantage would be,
1.Hard to analyse or understand the code.
2.If the recursive function is called for infinite no of
times and memory constrains are not taken care, then stack
overflow may occur So system may crash.
 
Is This Answer Correct ?    29 Yes 3 No
VadivelT
 
Answer
# 2
Advantage : Perform an action untill a condition
satisfies,Also for the repetative calls for inputting and
etc.
Disadvantage: If it encounters the infinite looping then
the stack overflow occurs it will cause ssem crash...
 
Is This Answer Correct ?    13 Yes 1 No
Suman Boddukuru
 
 
 
Answer
# 3
Recursion will be useful when same kind of job has to be
continued for a finite no input or time.

Eg: calculating series, finding factorial etc..

Disadvantage would be,
1.Hard to analyse or understand the code.
2.If the recursive function is called for infinite no of
times and memory constrains are not taken care, then stack
overflow may occur So system may crash.
 
Is This Answer Correct ?    13 Yes 3 No
Satyabrata Nayak
 
Answer
# 4
Recursion
Advantage
i. Usually simplicity.
ii. Although at most of the times a problem can be solved without recursion, but in some situations in programming, it is a must to use recursion. For example, a program to display a list of all files of the system cannot be solved without recursion.
iii. The recursion is very flexible in data structure like stacks, queues, linked list and quick sort.
iv. Using recursion, the length of the program can be reduced.
Disadvantage
i. It requires extra storage space. The recursive calls and automatic variables are stored on the stack. For every recursive calls separate memory is allocated to automatic variables with the same name.
ii. Often the algorithm may require large amounts of memory if the depth of the recursion is very large. If the programmer forgets to specify the exit condition in the recursive function, the program will execute out of memory.
iii. The recursion function is not efficient in execution speed and time.
iv. Some function calls inside recursion are repeated or duplicated just like fibonacci
 
Is This Answer Correct ?    2 Yes 0 No
Vasu Jain
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What are the various topologies? Which one is the most secure?   2
#include<stdio.h> #include<conio.h> # define swap(a,b) temp=a; a=b; b=temp; void main( ) { int i, j, temp; i=5; j=10; temp=0; if( i > j) swap( i, j ); printf( "%d %d %d", i, j, temp); } Burning-Glass 8
#include<stdio.h> int SumElement(int *,int); void main(void) { int x[10]; int i=10; for(;i;) { i--; *(x+i)=i; } printf("%d",SumElement(x,10)); } int SumElement(int array[],int size) { int i=0; float sum=0; for(;i<size;i++) sum+=array[i]; return sum; } output? Ramco 5
write a prgram of swapping with 2 valiables   6
can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance IBM 1
Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986   1
write a fuction for accepting and replacing lowercase letter to'Z' with out using inline function. Temenos 5
Which of the Following is not defined in string.h? A)strspn() B)strerror() C)memchr() D)strod() Accenture 2
When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it? Aloha-Technology 2
program in c to print 1 to 100 without using loop Wipro 9
write a c program to find the square of a 5 digit number and print the result. Accenture 4
post new interiew question and aptitude test papers   1
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com