Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does my Loop end after 11 Loops?
#69
(02-13-2023, 08:16 PM)Dimster Wrote: Do you feel with todays modern chips and buses there will still be a speed difference between iteration and recursion?

That depends on what you want to do. I have checked again now, and for certain programs, recursion can actually be faster than iteration; apparently when it comes to floating point arithmetic.
The program is written in C, and I have to try it first, then I can try to write it in Basic. If one want, one can try it oneself; see the screenshot*).

The book also reminded me that there are different types of recursion.
A) Direct recursion (faculty program)
B) Indirect recursion (program A calls B, and B calls A again)
C) Tail recursion
D) True recursion (Meant to state that it cannot be replaced by an iterative function)

The German translation of "tail recursion" is a gag:
C) Schwanzrecursion is in English: "cock recursion".  Big Grin

Yes, some things often only look simple at first glance!
The book: Leendert Ammeraal, Program design and algorithms in C, 2nd edition 1998

*)PS: I also made a PDF of it to copy the text, but it doesn't work. I can't copy the text from the file. No idea why not

[Image: Rekursion-Ammeraal.jpg]
Reply


Messages In This Thread
Why does my Loop end after 11 Loops? - by Dimster - 02-06-2023, 07:08 PM
RE: Why does my Loop end after 11 Loops? - by Kernelpanic - 02-13-2023, 10:13 PM



Users browsing this thread: 5 Guest(s)