Click here to Skip to main content
15,063,427 members

Comments by Avi Farah (Top 3 by date)

Avi Farah 11-Sep-17 17:06pm View
Again, your question is way too vague for me to comment on specifics. Are we still dealing with the same algorithm? How do the letters A, B, C, D apply to the algorithm.

My feeling is that you need to go after your logic, that you did not publish.

What comes to mind about your double recursive call is fibonacci series:
fibonacci[0] = f0 (a constant say 0)
fibonacci[1] = f1 (another constant say 1)
fibonacci[n] = fibonacci[n-2] + fibonacci[n-1]

This is a double recursive call (btw very computing time expensive)

However we can simplify/cheapen it: consider a 2 number tuple denoted by (x, y) then:
fib[0] = (f0, f1)
fib[n] = next(fib[n-1])

where next( (x,y) ) = (y, x + y)

and fibonacci[n] = fib[n].First

Now we succeeded to reduce a 2 recursive call to 1.

Hope this helps.
Avi Farah 6-Sep-17 16:51pm View
Your question is too vague.

In general to write a recursive program you need:
1. A recursive definition and
2. A terminating condition.

Your terminating condition is checked before your recursive-call and the recursive-call needs to get you closer to the terminating condition evaluating true, otherwise you will end up in an infinite recursion.

Hope this helps,
Avi Farah 11-Jan-17 21:39pm View
Nathan, thank you! I'm hoping to be able use an existing functionality as opposed to building the logic that is in the compiler. When I figure it out I'll post it.