📁
SICP
  • README
  • Building Abstractions With Procedures
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
Powered by GitBook
On this page
  • Exercise 1.10: The following procedure computes a mathematical function called Ackermann’s function.
  • What are the values of the following expressions?
  • Consider the following procedures, where A is the procedure defined above:
  • Give concise mathematical definitions for the functions computed by the procedures f, g, and h for positive integer values of n. For example, (k n) computes $| 5n^2 |$.

Was this helpful?

  1. Building Abstractions With Procedures

10

Exercise 1.10: The following procedure computes a mathematical function called Ackermann’s function.

(define (A x y)
  (cond ((= y 0) 0)
        ((= x 0) (* 2 y))
        ((= y 1) 2)
        (else (A (- x 1)
                 (A x (- y 1))))))

What are the values of the following expressions?

(A 1 10)

The steps under the hood:

(A 1 10)
(A 2 4)

The steps under the hood:

(A 2 4)
(A 3 3)

The steps under the hood:

(A 3 3)

Consider the following procedures, where A is the procedure defined above:

(define (f n) (A 0 n))
(define (g n) (A 1 n))
(define (h n) (A 2 n))
(define (k n) (* 5 n n))

Give concise mathematical definitions for the functions computed by the procedures f, g, and h for positive integer values of n. For example, (k n) computes $| 5n^2 |$.

Previous9Next11

Last updated 4 years ago

Was this helpful?

(f  n)=2n(f\;n) = 2n(fn)=2n
(g  n)=2n(g\;n) = 2^n(gn)=2n
(h  1)=h(1)=2(h\;1) = h(1) = 2(h1)=h(1)=2
(h  2)=h(2)=22(h\;2) = h(2) = 2^{2}(h2)=h(2)=22
(h  3)=h(3)=222(h\;3) = h(3) = 2^{2^{2}}(h3)=h(3)=222
.........
(h  n)=h(n)=h(n−1)(h\;n) = h(n) = h(n-1)(hn)=h(n)=h(n−1)