Vaja 1.10 g1smo

main
Jurij Podgoršek 2024-05-29 18:34:27 +02:00
parent 41eebcd583
commit b824fcdc5d
1 changed files with 131 additions and 0 deletions

View File

@ -137,3 +137,134 @@ TODO!
** 1.7 TODO
** 1.8 TODO
** 1.10 Ackermannov postopek
Sledeči postopek je Ackermannov:
#+begin_src scheme
(define (A x y)
(cond ((= y 0) 0)
((= x 0)
(* 2 y))
((= y 1) 2)
(else (A (- x 1)
(A x (- y 1))))))
#+end_src
Kakšni so rezultati sledečih izrazov?
- `(A 1 10)`
#+begin_quote
(A 1 10)
(A 0 (A 1 9))
(A 0 (A 0 (A 1 8)))
(A 0 (A 0 (A 0 (A 1 7))))
(A 0 (A 0 (A 0 (A 0 (A 1 6)))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 1 5))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 4)))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 3))))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 2)))))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 1))))))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 2)))))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 4))))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 8)))))))
(A 0 (A 0 (A 0 (A 0 (A 0 (A 0 16))))))
(A 0 (A 0 (A 0 (A 0 (A 0 32)))))
(A 0 (A 0 (A 0 (A 0 64))))
(A 0 (A 0 (A 0 128)))
(A 0 (A 0 256))
(A 0 512)
1024
#+end_quote
- `(A 2 4)`
#+begin_quote
(A 2 4)
(A 1 (A 2 3))
(A 1 (A 1 (A 2 2)))
(A 1 (A 1 (A 1 (A 2 1)))
(A 1 (A 1 (A 1 2)))
(A 1 (A 1 (A 1 2)))
(A 1 (A 1 (A 0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0 16384))
(A 0 32768)
65536
#+end_quote
- `(A 3 3)`
#+begin_quote
(A 3 3)
(A 2 (A 3 2))
(A 2 (A 2 (A 3 1)))
(A 2 (A 2 2))
(A 2 (A 1 (A 2 1)))
(A 2 (A 1 2))
(A 2 (A 0 (A 1 1)))
(A 2 (A 0 2))
(A 2 4)
(A 1 (A 2 3))
(A 1 (A 1 (A 2 2)))
(A 1 (A 1 (A 1 (A 2 1))))
(A 1 (A 1 (A 1 2)))
(A 1 (A 1 (A 0 (A 1 1))))
(A 1 (A 1 (A 0 2)))
(A 1 (A 1 4))
(A 1 (A 0 (A 1 3)))
(A 1 (A 0 (A 0 (A 1 2))))
(A 1 (A 0 (A 0 (A 0 (A 1 1)))))
(A 1 (A 0 (A 0 (A 0 2))))
(A 1 (A 0 (A 0 4)))
(A 1 (A 0 8))
(A 1 16)
65536
#+end_quote
Če imamo še sledeče postopke:
#+begin_src scheme
(define (f n) (A 0 n))
(define (g n) (A 1 n))
(define (h n ) (A 2 n))
(define (k n) (* 5 n n))
#+end_src
Jedrnato opredeli matematične funkcije izračuna postopkov `f`, `g` in `h`. `k`, recimo izračuna `5n^2`.
#+begin_quote
`f`: 2n
`g`: 2^n
`h`: 2^{2^n}
#+end_quote