zoukankan      html  css  js  c++  java
  • Exercise 1.10 Ackerman's function

    题目

    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)
    (A 2 4)
    (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*n.

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

    根据题意可知:

      A(N, 0)=0

      A(0,N)=2*N

      A(N, 1)=2

      A(X,Y)=A(X-1, A(X, Y-1))

    所以:

    1. F(N)=A(0,N)=2*N

    2. G(N)=A(1,N)

        =A(0, A(1, N-1)

        =2*A(1, N-1)

        =2*G(N-1)

     而G(0)=A(1,0)=0, G(1)=A(1,1)=2

      所以 G(N)=2^N 当N>=1时

    3. H(N)=A(2,N)

        =A(1, A(2, N-1))

        =2^(A(2,N-1))
        =2^H(N-1)

      A(2,0)=1

      A(2,1)=2

      所以 H(N)=2^H(N-1) 当N>=1时

  • 相关阅读:
    webapi 发布swagger
    如何在发布项目,并发布在iis上
    17.Github分支管理-解决冲突
    18.Git分支管理策略
    15.回撤操作
    16.Github分支管理-创建与合并分支
    14.查看信息深入讲解
    13.git commit深入讲解
    12.add-commit命令深入讲解
    11.几个Git新命令
  • 原文地址:https://www.cnblogs.com/linghuaichong/p/3973091.html
Copyright © 2011-2022 走看看