Thursday, April 4, 2013

Difference between Recursion and Iteration

RECURSION
ITERATIONS
Recursive function – is a function that is partially defined by itself
Iterative Instructions –are loop based repetitions of a process
Recursion Uses selection structure
Iteration uses repetition structure
Infinite recursion occurs if the recursion step does not reduce the problem in a manner that converges on some condition.(base case)
An infinite loop occurs with iteration if the loop-condition test never becomes false
Recursion terminates when a base case is recognized
Iteration terminates when the loop-condition fails
Recursion is usually slower then iteration due to overhead of maintaining stack
Iteration does not use stack so it's faster than recursion
Recursion uses more memory than iteration
Iteration consume less memory
 Infinite recursion can crash the system
infinite looping uses CPU
cycles repeatedly
Recursion makes code smaller
Iteration makes code longer

33 comments:

  1. this is exactly what i want to know thank you prof. bali

    ReplyDelete
  2. Nicely Explained, find the differences live with a c# example here

    http://www.samplecoder.com/2014/11/difference-between-recursion-and.html

    ReplyDelete
  3. Better than bookish languages. thank you sir.

    ReplyDelete
  4. Thank you so much sir. This helped a lot

    ReplyDelete
  5. thanks...
    it helped me in my exam.

    ReplyDelete
  6. sir what is tree iterators in c++

    ReplyDelete
  7. Superb explanation....
    Like that sir

    ReplyDelete
  8. Superb explanation....
    Like that sir

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. sir is branching and recursion are same or different

    ReplyDelete
  11. now this concept is clear....thank u very much prof. Bali

    ReplyDelete
  12. sir , Can you give practical example ?
    theory is nice but i need practical example.

    ReplyDelete
  13. seriously, its best!! I appreciate your job.... awesome..

    ReplyDelete
  14. to the point what i liked about it :))

    ReplyDelete
  15. You have explained nicely about difference between recursion and iteration in tabular form. Thanks for sharing the information.

    ReplyDelete
  16. Top 10 titanium ore (trimals) from China
    Top babyliss nano titanium flat iron 10 titanium ore urban titanium metallic (trimals) from titanium flash mica China. A popular type of ore. This type is a highly volatile ffxiv titanium nugget ore and has titanium dog teeth many benefits including a higher volatility,

    ReplyDelete

ECCF Question Describe the Block diagram of Operational Amplifier Draw the pin diagram of  µA 741 op-amp Draw the schematic diagram o...