answersLogoWhite

0


Best Answer

Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.

Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.

User Avatar

Wiki User

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

Wiki User

11y ago

A recursive call occurs whenever a function calls itself, recursively. Recursive functions are often used when a solution requires a divide and conquer technique. In other words, each instance of the function reduces a large problem into smaller instances of the same problem, until a base case is reached. When all instances reach the base case, the large problem is fully resolved.

There is no data structure associated with recursive calls, however a recursive function makes use of the call stack to maintain the state of its local variables between recursive calls. That is, each instance works on its own discrete set of local variables, completely independent of all other instances. If there is no need to maintain the state of these variables after a recursive call, then recursion may not be the best solution to the problem (an iterative loop would likely be more efficient).

By way of an example, consider the Quick Sort algorithm which is a recursive function. This function receives the lower and upper bounds of an array which will initially be the entire array. During recursion, the lower and upper bounds will represent a subset of the array. When the subset has fewer than 2 elements, the function returns (this is the base case because you cannot sort fewer than 2 elements). If there are 2 or more elements, a pivot element is selected and the array is sorted such that elements to the left of the pivot are less than the pivot, while those to the right are greater or equal to the pivot. The pivot is then in its correct place, but the sets on either side remain unsorted (but on the correct side of the pivot). Since each of these two sets is simply a smaller version of the larger problem, two recursive calls are made, one for the left set, another for the right set. When the second recursive call returns, the function has completed its task and returns itself. Ultimately, each set goes through the same process, gradually dividing and subdividing the set until all subsets have reached the base case, at which point the entire array is sorted.

Although it would be possible to implement the Quick Sort algorithm as an iterative loop, recursion is much easier because of the need to maintain the lower and upper bound of the subset (which are received as arguments), as well as the pivot index (which is a local variable) within each instance. these variables are required in order to determine the lower and upper bound of the right subset, immediately after the left subset has been processed.

It should be noted, however, that once the right side of the array is processed, the function will immediately return. So there is no need to maintain the variable states from this particular call. Function calls, especially recursive calls, are expensive. So while recursion is required to process the left side of the array, it would be more efficient to simply modify the variables and recall the same instance of the function (known as a tail call), rather than make a recursive call for the right side of the array. And while this is more efficient, the function can be made yet more efficient by making a recursive call on the smaller of the two sets, and a tail call on the larger -- thus greatly reducing the depth of recursion.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

In writing a program of recursion we do not need any data structure.

But the assembler uses the datastructure and it is stack.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Assalam o alaikum Sir i want yousuf raza gelani e-mail address plz for give me i need help plz

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Stacks. The computer used a built-in stack to execute recursive and normal function calls.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Stack.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

list

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a recursive call. Which data structure is used in it?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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.


Which data structure used in database?

You create your own data structure in database.


What data structure and logarithm?

data structure is a way of storing data in a computer so that it can be used efficientlyan algorithm is a sequence of instructions, often used for calculation and data processing.Often a carefully chosen data structure will allow the most efficient algorithm to be used.


What the data structure is used behind FACEBOOK?

The GRAPH data structure used behind Facebook.for more detail see


Is data structure a language?

No, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.


What data structure is used to store homogeneous data item?

array


Which type of data structure is used in ATM to take the printout of last 5 transactions?

stack data structure.


What is the main purpose of the structure?

To arrange data in a particular manner.these manner or set of rules is defined in the data structure so that the data used in computer systems can properly used at necessary time.


What are the goals of data structure?

To arrange data in a particular manner.these manner or set of rules is defined in the data structure so that the data used in computer systems can properly used at necessary time.


Which data structures used in T9 dictionary?

Tries, it is a kind of tree data structure that can be used.


How would a person explain data structures to a technophobe?

It is possible to explain data structure in layman's terms. Simply put, in computer terms, a data structure is a commonly used method of data organization.


What is data structure?

The data structures are user defined data types specifically created for the manipulation of data in a predefined manner. Examples of data structures would be stacks,queues,trees,graphs and even arrays(also reffered as data structure)