2c03-review - 00100

2c03-review - 00100 - The following recursive procedure...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
2 Using find 2 a b b b a b b a a b b a b a a b a b a a b a a b a a b a b b a b b b a b b a # pass1 a b a 3 pass2 a 1 pass3 a 1 pass4 a b a 3 pass5 a 1 pass6 a b 2 pass7 a b a 3 pass8 a 1 pass9 a b a a b a a 7 pass10 (a b a) a 1 pass11 (a) b a a b a a b a b 9 pass12 (a b a a b a) a b a b 4 36 2[15]. A function K(n,m,k) is defined as follows: K(n,m,k) = if n<1 or m<1 or k<1 then K:=1 else if m>k then K:=K(n-1,m-2,k-1)+2*K(n-2,m-3,k) else K:=2*K(n-2,m-1,k-1)+K(n-3,m,k-1)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The following recursive procedure computes K(n,m,k): procedure KK(n,m,k : integer ; var K : integer); var K1 : integer; begin if n<1 or m<0 or k<1 then K : = 1 else if m>k begin KK(n-1,m-2,k-1,K); K1 := K; KK(n-2,m-3,k,K); K := K1+2*K; end else begin KK(n-2,m-1,k-1,K); K1:=K; KK(n-1,m,k-1); K:=2*K1+K; end end ;...
View Full Document

This note was uploaded on 12/10/2009 for the course CAS 2c03 taught by Professor Janicki during the Spring '03 term at McMaster University.

Ask a homework question - tutors are online