Base case in a recursive method

后端 未结 4 857
遇见更好的自我
遇见更好的自我 2020-12-05 20:45

A theoretical question here about the base or halting case in a recursive method, what\'s its standards?

I mean, is it normal not to have body in it, just a retu

4条回答
  •  借酒劲吻你
    2020-12-05 21:02

    The pattern for recursive functions is that they look something like this:

    f( value ) 
       if ( test value )
          return value
       else
          return f( simplify value )
    

    I don't think you can say much more than that about general cases.

提交回复
热议问题