# 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 pr…ogrammed: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 Algorithmstatic 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

# 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; }

# 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

# Adjective example and explain the examples?

adjectives describe things (nouns). A large dog. The adjective is large it describes the dog (noun). A big black dog. The adjectives are big and black they describe the do…g (noun). She is hungry. The adjective is hungry it describes she (pronoun). Your dog is bigger than my dog. This is a comparative adjective it compares two things (your dog and my dog). My dog is the biggest. This is a superlative adjective it tells us that something has some feature to a greater degree than anything it is being compared to.

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

In Technology

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

Entirely different things, no point in comparison.