mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-22 02:36:48 +08:00
25 lines
734 B
Markdown
25 lines
734 B
Markdown
# Section 3 - Pre-computation
|
|
|
|
Time versus space.
|
|
|
|
This is the essential battle that programmers face. In order to go
|
|
faster, more memory is used. In order to economize on memory, more
|
|
computation is needed.
|
|
|
|
This duality is demonstrated in no better way than comparing a
|
|
calculated method (economizing space at the expense of time) versus an
|
|
entirely precomputed method (sacrificing space to reduce time).
|
|
|
|
In this section, we will demonstrate three methods of calculating
|
|
factorials from 0 to 15.
|
|
|
|
* Iteratively
|
|
|
|
* Recursively
|
|
|
|
* By pre-computation
|
|
|
|
Certainly, for the purposes of this demonstration, it is not necessary
|
|
to implement both iterative and recursive methods. We do so for fun and
|
|
for any lessons the reader can glean.
|
|
|