answersLogoWhite

0


Best Answer

Recursive procedures are huge memory hogs. Also, they're a nightmare to debug. Finally, it's pretty rare to find an application that actually needs recursion as opposed to a simpler, more friendly methodolgy.

User Avatar

Wiki User

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

Wiki User

12y ago

In computer science, recursion is the reference of a function to itself. In general, recursion simplifies the programmer's task by saving a certain amount of code, thus making it more compact. It can also simplify the appearance of a program. A classical example of recursion is the C function for n! which contains the assignment nfact=f(nfact-1);

where f is the name of the function andnfact is the value of the factorial being computed.The mathematical form of this assignment is simplyn!=n(n-1)! .

Recursion also has its disadvantages. It can hamper debugging and slow down complicated computing processes. When a process can be done either by recursion or by iteration, the latter should usually be preferred.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Dynamic programming is a computer science methodology that uses previous choices or decisions to formulate the next solution. The main limitation to this type of coding is keeping track of previous decisions and partial choices that may be applied to a future answer.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Demerits of recursion are:

Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods.

Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space.

The recursive programs take considerably more storage and take more time during processing.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Recursion

Advantage

i. Usually simplicity.

ii. Although at most of the times a problem can be solved without recursion, but in some situations in programming, it is a must to use recursion. For example, a program to display a list of all files of the system cannot be solved without recursion.

iii. The recursion is very flexible in data structure like stacks, queues, linked list and quick sort.

iv. Using recursion, the length of the program can be reduced.

Disadvantage

i. It requires extra storage space. The recursive calls and automatic variables are stored on the stack. For every recursive calls separate memory is allocated to automatic variables with the same name.

  1. Often the algorithm may require large amounts of memoryif the depth of the recursion is very large. If the programmer forgets to specify the exit condition in the recursive function, the program will execute out of memory.
  2. The recursion function is not efficient in execution speed and time.
  3. Some function calls inside recursion are repeated or duplicated just like fibonacci
This answer is:
User Avatar

User Avatar

Wiki User

11y ago

To perform recursion the data structure 'stack' is used.

Stack has LIFO(Last in First out) property and it remember it's 'caller'.

Therefore, when the function has to return it knows to whom it should return.

Recursion makes use of the system stack for storing the return addresses of the fn calls.

Every recursion fn has its equivalent non-recursive function.

When such equivalent non-recursive fn procedures stack is to be used to perform recursion.

Recursive relation ships if exists then function coding becomes easy.

Because of repeated recursion, we may enter into stack overflow problem. To avoid this we try to see that the recursive relation can be realized tail recursive manner. In direct recursion for each one activation frame will be created from the stack area of our process, thus it may lead to stack overflow situation. When we realize in tail recursive manner, with one activation record or stack frame itself we can get the results.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

You cannot have recursion within a data structure. Recursion applies to functions and compile-time computation (template metaprogramming).

The following is an example of recursion in a data structure:

typedef struct object {

struct object data;

};

This won't compile because the declaration of object is incomplete at the point we declared the data member. It has a cyclic dependency that, if allowed, would recurse into infinity. That is, in order to instantiate an object, we must first instantiate the object.data member. But that data member is itself an object, so we cannot instantiate it until we've instantiated object.data.data, and object.data.data.data, and so on into infinity.

To break the cyclic dependency we have to use a pointer to the type rather than an instance of the type:

typedef struct object { struct object* data_ptr;

};

Note that we can point to incomplete types because a pointer is a complete type, even if the type it points to is incomplete. This is because the pointer is not instantiated until we instantiate an object of the type, and we can only do that when the type is complete:

struct object obj; // instantiate an object

obj.data_ptr = &obj; // assign the address of the object to its own data pointer

The above is an example of a self-reference, not an example of recursion.

struct object obj2;

obj.data_ptr = &obj2;

obj2.data_ptr = &obj;

In this example, the two objects are pointing to each other. Again, this is non-recursive.

We can also copy a member pointer to a non-member pointer via a member pointer:

struct object* p = obj.data_ptr->data_ptr;

Again, not recursive! Note that p is now pointing at obj, not obj2.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

answer ede bey

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Yes.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is advantages of recursion in a data structure?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which data structure is used for recursion?

this question depends on what the recursion is being used for..... sumit kumar srivastava 9455587002


Advantages and disadvantages of using recursion?

pata nhe


What is a high speed data searching and sorting in data structure algorithm?

Binary Search is the high speed data searching.Here in each recursion the is divided in two equal halves so that execution becomes easier.


What are the advantages and dis advantages of file?

file is data storage structure it is collection of record


List advantages and disadvantages for data structure diagrams?

uqwyhvxuyhasbxiuqa


Can heap implement recursion?

Heap is a data-structure, it cannot implement anything. On the other hand, it is true that: 1. Recursive routines might use heap. 2. You can use dynamic memory allocation (heap), to implement a stack; and use the stack to implement recursion.


What data structures are used for implementing backtracking branch and bound?

Recursion is used for backtracking


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.


What are the advantages of data structure?

The tree structure is useful because it easily accommodates the creation and deletion of folders and files.


What are the subject-matters of data structure?

types of data structure types of data structure


What are the Advantages of a data projector to a teacher?

what are the advantages of a data projector


How do you amend a data structure?

How do you amend a data structure?