answersLogoWhite

0

What is recursive algorithm?

Updated: 8/10/2023
User Avatar

Wiki User

15y ago

Best Answer

Algorithm can be defined as an interpretable, finite set of instructions for dealing with contigencies and accompanying task that has recognizable end-points for given inputs. It is a tool for solving a well computational problem. A recursive algorithm is one which calls itself.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

A recursive method is a method that can invoke itself. The classical example is N factorial...

int nfact (int N) {

if (N == 2) return N else return N * nfact (N - 1);

}

The example suffers from truncation issues, because N Factorial gets very large, very quickly, with relatively small values of N, and ordinary integers do not support that. The answer, however, is sufficient for the question of "what is a recursive method?"

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

A recursive program/algorithm is one that calls itself again.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is recursive algorithm?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

When you choose iterative or recursive algorithm?

If you cannot find any iterative algorithm for the problem, you have to settle for a recursive one.


What is recursive call in terms of algorithm?

A recursive call in an algorithm is when a function (that implements this algorithm) calls itself. For example, Quicksort is a popular algorithm that is recursive. The recursive call is seen in the last line of the pseudocode, where the quicksort function calls itself. function quicksort('array') create empty lists 'less' and 'greater' if length('array') ≤ 1 return 'array' // an array of zero or one elements is already sorted select and remove a pivot value 'pivot' from 'array' for each 'x' in 'array' if 'x' ≤ 'pivot' then append 'x' to 'less' else append 'x' to 'greater' return concatenate(quicksort('less'), 'pivot', quicksort('greater'))


What causes a recursive algorithm to stop calling itself?

If the condition has been reached.


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

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


What is recursive algorithm and write a recursive algorithm to reverse a string also trace it for any string data?

A recursive algorithm is an algorithm which calls itself with "smaller (or simpler)" input values, and which obtains the result for the current input by applying simple operations to the returned value for the smaller (or simpler) input. Heres a recursive algorithm to reverse a string char *rev(char str[],int pos1,int pos2) { if(pos1<pos2) { char temp=str[pos1]; str[pos1]=str[pos2]; str[pos2]=temp; return rev(str,pos1+1,pos2-1); } return str; } You can call this function like this char *r=rev("reverse it",0,9);

Related questions

When you choose iterative or recursive algorithm?

If you cannot find any iterative algorithm for the problem, you have to settle for a recursive one.


What is recursive call in terms of algorithm?

A recursive call in an algorithm is when a function (that implements this algorithm) calls itself. For example, Quicksort is a popular algorithm that is recursive. The recursive call is seen in the last line of the pseudocode, where the quicksort function calls itself. function quicksort('array') create empty lists 'less' and 'greater' if length('array') ≤ 1 return 'array' // an array of zero or one elements is already sorted select and remove a pivot value 'pivot' from 'array' for each 'x' in 'array' if 'x' ≤ 'pivot' then append 'x' to 'less' else append 'x' to 'greater' return concatenate(quicksort('less'), 'pivot', quicksort('greater'))


Recursive algorithm to check a no is prime or not?

Suck a dick until it works


What causes a recursive algorithm to stop calling itself?

If the condition has been reached.


How can you convert a simple algorithm to recursive algorithm?

Linear search(a,item) n=length(a) for i=1 to n do if(a[i]==item) then return i end for return -1


What is base case?

A base case is the part of a recursive definition or algorithm which is not defined in terms of itself.


What is a base case?

A base case is the part of a recursive definition or algorithm which is not defined in terms of itself.


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

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


What is recursive algorithm and write a recursive algorithm to reverse a string also trace it for any string data?

A recursive algorithm is an algorithm which calls itself with "smaller (or simpler)" input values, and which obtains the result for the current input by applying simple operations to the returned value for the smaller (or simpler) input. Heres a recursive algorithm to reverse a string char *rev(char str[],int pos1,int pos2) { if(pos1<pos2) { char temp=str[pos1]; str[pos1]=str[pos2]; str[pos2]=temp; return rev(str,pos1+1,pos2-1); } return str; } You can call this function like this char *r=rev("reverse it",0,9);


Design recursive algorithm for computing 2n for any non negative integer n which is based on the formula2n2n-1 2n-1?

The formula, as far as I can see, is not appropriate for the algorithm.


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


Where do you run an algorithm?

By preparing test cases we can test an algorithm. The algorithm is tested with each test case.