answersLogoWhite

0


Best Answer

If the condition has been reached.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What causes a recursive algorithm to stop calling itself?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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 is recursive algorithm?

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.


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);


What is a recursive relationship?

a function that recalls itself again and again is called recursive relationship.


Difference between function and recursive variable?

A function can map for sets with infinite elements. Recursive variables, being 'algorithms of algorithms', are restricted to finite elements.

Related questions

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 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.


What is recursive algorithm?

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.


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);


What is a recursive relationship?

a function that recalls itself again and again is called recursive relationship.


What is a recursive research method?

an answer that refers to itself.


Difference between function and recursive variable?

A function can map for sets with infinite elements. Recursive variables, being 'algorithms of algorithms', are restricted to finite elements.


When a single entity is related to itself then the relationship is termed as?

It will be a recursive relationship.


What is recursive calls.which data structure is used in it?

A recursive call is any function that calls itself with modified parameters. There is no data structure associated with it, other than the call stack which is associated with all function calls, recursive or not. The stack is used to store the state of the current instance's local variables, the return address, and the arguments to be passed to the next instance. This allows recursive calls to "unwind" in the reverse order they were called. Recursive functions must have a terminating condition as all the recursive calls must eventually return to the original caller at some point. If they don't, they'll simply keep calling themselves until there's no more space on the stack. Recursive functions are commonly used in divide-and-conquer algorithms, gradually reducing larger problems down to smaller instances of the same problem until a terminating condition is satisfied. As the calls return, the larger problem is gradually solved until the function returns to the original caller, at which point the entire problem is fully resolved. Quicksort is a typical algorithm that makes use of recursion.


What is a pattern that repeats itself called?

An algorithm.


Which data structure would you most likely see in a nonrecursive implementation of a recursive algorithm?

Some sort of structure that lets you store a list of pending jobs - for example, an array, but it would have to be a resizable array. Some type of collection might be more appropriate. As you process one level of recursion, you add the "children" (which have yet to be processed) to the collection of pending jobs; once the "parent" is done processing, you remove it from the collection.