State some examples of recursive functions?

Author Topic: State some examples of recursive functions?  (Read 1008 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 158
  • Karma: 0
    • Hot Shaper
State some examples of recursive functions?
« on: 04-04-2016, 04:22:57 »
Examples of recursive functions are as follows:-
Factorial of a given number
Palindrome
Fibonnaci series
GCD


Offline friendhrm

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 1
  • Posts: 47
  • Karma: 0
    • Friend HRM
Re: State some examples of recursive functions?
« Reply #1 on: 12-20-2017, 00:43:07 »
The rule of thumb for recursion is, "Use recursion, if and only if on each iteration your task splits into two or more similar tasks".

So Fibonacci is not a good example of recursion application, while Hanoi is a good one.

So most of the good examples of recursion are tree traversal in different disquises.

For example: graph traversal - the requirement that visited node will never be visited again effectively makes graph a tree (a tree is a connected graph without simple cycles)

divide and conquer algorithms (quick sort, merge sort) - parts after "divide" constitute children nodes, "conquer" constitues edges from parent node to child nodes.

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
2505 Views
Last post 05-14-2016, 02:20:24
by TomClarke
1 Replies
1848 Views
Last post 04-27-2016, 04:51:59
by TomClarke
0 Replies
1099 Views
Last post 02-25-2016, 03:59:05
by chinmay.sahoo
0 Replies
767 Views
Last post 12-28-2016, 00:47:12
by chinmay.sahoo
3 Replies
5147 Views
Last post 02-01-2018, 07:15:54
by RH-Calvin