FOR MORE EXAMS EMAIL
WGU C960:Recursion Latest updated exam
questions and answers 2026-2027
Recursion problems
1 The following algorithm computes the GCD of two integers. The function
remainder(n,m) calculates the remainder of the division n divided by m
(n = qm + r).
Algorithm 1 GCD
1: procedure GCD(n,m)
2: r := remainder(n,m)
3: if r == 0
4: return m
5: else
6: GCD(m,r)
1. If you execute the command GCD(21,99) how many time, in total, will
the function GCD be called?
2. What are the inputs of each of those calls?
3. Will GCD(n,m) always equal GCD(m,n)?
4. If n > m which will call GCD more times, GCD(n,m) or GCD(m,n)?
Solution:
1. GCD will be called a total of 4 times:
2. GCD(99,21), GCD(21,15), GCD(15,6), GCD(6,3).
3. Yes.
Suggestions or errors? Thursday 25th June, 2020
Contact the author: Dr.Nina Rupert.
, C960:Recursion PracticeProblems
4. The first call of GCD(99,21) is GCD(21,99) since 21 = 0 · 99 + 21. A
similar thing will happen whenever the first entry is larger than the
second. Therefore, there is always exactly one more call in
GCD(n,m) than GCD(m,n).
2 Evaluatethefollowingrecursivealgorithmat6andat7. Explain,inyourownwords,whatthis
algorithmdoes.
Algorithm 2 Double Factorial
1: procedure DFACTORIAL(n) 2:
input: a non-negative integer n
3:
4: if n = 1 or 0 return 1
5: r := DFactorial(n - 2)
6: return (r*n)
Solution: DFactorial(6) calls on the function for n = 6,4,2,0.
DFactorial(0) = 1, then
2 ∗ Dfactorial(0) = 2, DFactorial(4) = 4 ∗ Dfactorial(2) = 8, finally
DFactorial(6) = 6 ∗ Dfactorial(4) = 48.
DFactorial(7) calls on the function for n = 7,5,4,1. DFactorial(1) = 1, then
DFactorial(3) = 1 ∗ Dfactorial(0) = 3, DFactorial(5) = 5 ∗ Dfactorial(3) =
15, finally DFactorial(7) = 7 ∗ Dfactorial(5) = 105.
DFactorial(2) =
In general, Dfactorial(n) is the product of every other positive integer
between 1 and n, starting with n and going down. Alternatively it is the
product of every integer of the same parity (even or odd) as n between 1
and n.
Suggestions or errors? Page 2 of 6 Thursday 25th June, 2020
Contact the author: Dr.Nina Rupert.
WGU C960:Recursion Latest updated exam
questions and answers 2026-2027
Recursion problems
1 The following algorithm computes the GCD of two integers. The function
remainder(n,m) calculates the remainder of the division n divided by m
(n = qm + r).
Algorithm 1 GCD
1: procedure GCD(n,m)
2: r := remainder(n,m)
3: if r == 0
4: return m
5: else
6: GCD(m,r)
1. If you execute the command GCD(21,99) how many time, in total, will
the function GCD be called?
2. What are the inputs of each of those calls?
3. Will GCD(n,m) always equal GCD(m,n)?
4. If n > m which will call GCD more times, GCD(n,m) or GCD(m,n)?
Solution:
1. GCD will be called a total of 4 times:
2. GCD(99,21), GCD(21,15), GCD(15,6), GCD(6,3).
3. Yes.
Suggestions or errors? Thursday 25th June, 2020
Contact the author: Dr.Nina Rupert.
, C960:Recursion PracticeProblems
4. The first call of GCD(99,21) is GCD(21,99) since 21 = 0 · 99 + 21. A
similar thing will happen whenever the first entry is larger than the
second. Therefore, there is always exactly one more call in
GCD(n,m) than GCD(m,n).
2 Evaluatethefollowingrecursivealgorithmat6andat7. Explain,inyourownwords,whatthis
algorithmdoes.
Algorithm 2 Double Factorial
1: procedure DFACTORIAL(n) 2:
input: a non-negative integer n
3:
4: if n = 1 or 0 return 1
5: r := DFactorial(n - 2)
6: return (r*n)
Solution: DFactorial(6) calls on the function for n = 6,4,2,0.
DFactorial(0) = 1, then
2 ∗ Dfactorial(0) = 2, DFactorial(4) = 4 ∗ Dfactorial(2) = 8, finally
DFactorial(6) = 6 ∗ Dfactorial(4) = 48.
DFactorial(7) calls on the function for n = 7,5,4,1. DFactorial(1) = 1, then
DFactorial(3) = 1 ∗ Dfactorial(0) = 3, DFactorial(5) = 5 ∗ Dfactorial(3) =
15, finally DFactorial(7) = 7 ∗ Dfactorial(5) = 105.
DFactorial(2) =
In general, Dfactorial(n) is the product of every other positive integer
between 1 and n, starting with n and going down. Alternatively it is the
product of every integer of the same parity (even or odd) as n between 1
and n.
Suggestions or errors? Page 2 of 6 Thursday 25th June, 2020
Contact the author: Dr.Nina Rupert.