Question on recursion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ariharan
    New Member
    • Aug 2007
    • 20

    Question on recursion

    Is this a recursion
    Code:
    main()
    {
      fun1();
    }
    fun1()
    {
      fun2();
    }
    fun2()
    {
      fun1();
    }
    Last edited by Ganon11; Feb 17 '08, 06:54 AM. Reason: Please use the [CODE] tags provided.
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    Originally posted by Ariharan
    Is this a recursion
    main()
    {
    fun1();
    }
    fun1()
    {
    fun2();
    }
    fun2()
    {
    fun1();
    }
    Yes,this is a recursion.
    But called as indirect recursion

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      It will result in an infinite loop. I hope that in your actual code you take measures to avoid this.

      Comment

      • Ariharan
        New Member
        • Aug 2007
        • 20

        #4
        Originally posted by Ganon11
        It will result in an infinite loop. I hope that in your actual code you take measures to avoid this.
        In my actual code there is a condition that terminates infinite loop...

        Comment

        Working...