# What is an example of using recursive functions?

Answer Let's take the example of finding the factorial of a number (of a positive integer). The factorial of N is N * (N-1) * (N-2) * (N-3…) ... * 3 * 2 *1 It is the product of all integers between that number (including that number) and 1. For example, factorial 2 = 2*1 = 2 factorial 3 = 3*2*1 = 6 factorial 4 = 4*3*2*1= 24 Now you define a recursive function Fac (N) as Fac (N) = Fac (N-1) * N, with Fac(1) predefined as 1. Thus, Fac(N-1) = Fac(N-2) * (N-1) and Fac(N-2) = Fac(N-3) * (N-2) and thus recursion takes over until such time fac(1) needs to be evaluated. We know the value of Fac(1) which is set as 1. Thus we can evaluate Factorial(N) using recursion.

# What is recursion?

Read answer of question: "What is recursion?" .
Recursion in computer science is a way of 'Thinking About' and then 'Solving' problems. How does it look in reality when …programmed: int func1(int input1) { if(base condition) { return some finite value. } else { return func1(input2) //Function calls itself. } } So, to design a solution(algorithm) to any problem in such a way that one function is having a call to itself inside a body and problem is reduced in each successive self calls to that limit that we reach base condition that returns some result(finite value) and no further recursive calls are made further. This makes a recursive solution and this way of solving the problem is called 'Recursion'. Examples of recursive problems: 1.Check given string is a palindrome. E.g. 'RACECAR'. 2.Factorial of number. 3.Calculating nth term of 'Fibonnaci' series. E.g. if n = 4. Then series is 0,1,1,2,3 4.Binary Search 5.Greated Commom Divisor (GCD) calculation. Palindrome Recursive Algorithm static int depth; //GLOBAL CLASS VARIABLE public bool IsPalindrome(string PalindromeString) { depth++;//STANDARD if (depth 1) //STANDARD { PalindromeString = PalindromeString.ToUpper().Trim();//ONE TIME WORK if (PalindromeString.Equals(string.Empty) || PalindromeString null) //STANDARD - STOP CONDITION BASED ON INITIAL CONDITIONS { return false; } } if (PalindromeString.Length

# Can anybody explain stack level functioning of recursion in c language exclusively?

Yes, any body can explain stack level functioning of recursion in Clanguage exclusively. ;-) Whenever we invoke a function, the return address is pushed ontothe call stack. Th…at return address remains on the call stack untilthe function returns at which point the address is popped from thestack and control passed to that address. In this way, functionscan always find their way back to their callers, even if thosefunctions invoke other functions, including themselves (recursivefunctions). As well as the return address, the formal arguments of the functionand the local variables of the function are also pushed onto thestack. Formal arguments are initialised by the actual argumentspassed by the caller, assigning the values of the actual argumentsto the formal arguments. If the formal argument is a pointervariable or reference, the address of the actual argument is passedinstead. In addition, the call stack is used by the exception handlingmechanism. When an exception is thrown by a function, the callstack "unwinds" (popping each function's stack frame) until asuitable handler is found.

# Examples using recursive procedure in the C computer programming language?

int factorial (int n) { if (n == 1) return 1; else return factorial (n - 1) * n; }

# What is recursive?

In computer programming, a function can call another function. If a function calls itself, it is said to be recursive. Doing this correctly can it quite simple to solve certai…n problems, that otherwise look very complicated. In math, a function is defined as recursive when it is defined in terms of itself. For example, the factorial of a number is the product of all numbers up to this number. Thus, the factorial of 4, written 4!, is equal to 1 x 2 x 3 x 4. A common definition for this function is as follows: 0! = 1, for all numbers "n" greater than zero, n! = n x (n-1)! For example, the factorial of 4 (which is 4 x 3 x 2 x 1) is equal to 4 times the factorial of 3 (which is 3 x 2 x 1).

# Write a example of recursion?

Following function calculates factorial of a number using recursion. unsigned int factorial(unsigned int a) { if (a == 1) return 1; else { a *= factorial(a-1)…; return a; } } recursion n. see recursion.

# Explain the term Recursion with example?

recursive definition of a function is defined in which the function is defined in terms of itself.here the fuction calls itself repetitively.

# What is recursiveness?

Assuming you mean "recursion", recursion is a function calling itself. A good example of when you would use recursion is for a directory walker. You would call the function, p…assing it a directory path. The function would call itself for all the directories in the directory you passed in. It would then do whatever processing it needed to on all the files in the directory.

# Write and explain recursive backtracking algorithm for n-queens?

This is not a question, this is your homework. For a start, read this: https://en.wikipedia.org/wiki/Eight_queens_puzzle

# What is an example of a recursive pattern that has 2 and 9 as the first two terms?

a pattern is a pattern guys come on u shoul know that is really very esay i want tell you the answerthink by your self

# Find an example or a recursive procedure and represent it as an iterative procedure?

int recursiveNFactorial (int n) { if (n < 2) return 1; if (n == 2) return n; else return n * recursiveNFactorial (n - 1); } int iterativeNFactorial (int n) { int res…ult = 2; if (n < 2) return 1; while (n > 2) result *= n--; return result; }

Answered

In Technology

# Explain non-recursive and recursive algorithm for postorder traversal on binary tree?

Step 1:- select first root node (t), start travelsing left contin

Answered

In Uncategorized

# What is the purpose of a stack in implementing a recursive procedure Explain?

there is no a prior limit on the depth of nested recursive calls (that a recursive function may call itself any no. of times), we may need to save an arbitrary number of regis…ter values(return values of the recursive functions, that may be used latter to find the actual solution). These values must be restored in the reverse of the order in which they were saved, since in a nest of recursions the last subproblem to be entered is the first to be finished. This dictates the use of a stack, or ``last in, first out'' data structure, to save register values. We can extend the register-machine language to include a stack by adding two kinds of instructions: Values are placed on the stack using a save instruction and restored from the stack using a restore instruction. After a sequence of values has been saved on the stack, a sequence of restores will retrieve these values in reverse order. Vishal Srivastava MCA, LU source : http://mitpress.mit.edu/sicp/full-text/sicp/book/node110.html

Answered

In Technology

# What do you mean by recursive function explain with suitable example?

Type your answer here...

Answered

In Technology

# What is recursion in c explain with the help of an example?

Recursion is the technique of a function calling itself, rather than iterating through the use of loops. The classic example of a recursive function is the computation of N Fa…ctorial... int nfact (int n) if (n 2) return n else return n * nfact (n - 1); If you call this with n 5, for instance, it will call itself an additional 3 times, so you will have 4 stack frames where the local value of n is 5, 4, 3, and 2. When you get to the last call, you unwind the stack frames, and the multiplication of 2, 3, 4, and 5 takes place. This example is for illustration only. It fails miserably with even small values of n (13, using 32-bit arithmetic) due to integer overflow, because N Factorial get large quickly.

Answered

# What is main difference between function and recursion explain with example?

Entirely different things, no point in comparison.