sicp-solutions/ex-1.26.txt
Petar Kapriš a697f52405 Add solutions to exercises from section 1.2
To be noted: the drawing in exercise 1.14 is unfinished. I did it in a
notebook, but haven't yet had the time to put it in a txt file.
2025-02-05 13:59:25 +01:00

10 lines
438 B
Text

Essentially, instead of us halving the time of computation,
every time we have an even number, we instead halve the expmod call
but then, make that call twice, in other words, instead of
(specifically for even number):
T(n) = O(1) + T(n/2)
we get:
T(n) = O(1) + 2*T(n/2), which is going to give us roughly:
O(n)
We get a recursion tree, growing exponentially with at every recursive call,
of which there are O(log n), so exp(log(n)) = n.