Thread: C or C++ ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by yvan
    you need recursion for example to solve some problems algorithmically
    Just because an algorithm is implemented with recursion does not mean your language of choice needs to support recursion. You can use an explicit stack to simulate the effects of recursion. Additionally, in algorithms that use "tail recursion" (calling the recursive procedure at the end of the procedure code itself) it could/should be rewritten as a loop, because nothing can happen until you reach the base case, and the stack of function calls unwinds. The only reason you see tail recursion is because it is simple to write.
    Last edited by whiteflags; 03-10-2016 at 01:43 PM.

Popular pages Recent additions subscribe to a feed