The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+2 votes
56 views

Consider the code below, defining the function $A$:

A(m, n, p) {
    if (p == 0) return m+n;
    else if (n == 0 && p == 1) return 0;
    else if (n == 0 && p == 2) return 1;
    else if (n == 0) return m;
    else return A(m, A(m,n-1,p), p-1);
}

Express $A(m, n, 2)$ as a function of $m$ and $n$.

in Algorithms by Veteran (100k points) | 56 views

1 Answer

+1 vote

A(m,n, 2) = A(m,A(m, n-1, 2), 1)

Similarly Here

A(m, 0, 2) = 1 = m0.

A(m, n-1, 2) = mn-1

So A(m,n,2)=A(m,A(m, n-1, 2), 1)

                   =A(m , mn-1 ,1 )

      A(m,n,2)=m*mn-1 =mn

by Boss (38.3k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,092 questions
55,322 answers
190,846 comments
86,220 users