CSC508 – Data Structures
Lab Exercise 7
Recursion
Exercise 1
• Define the method for the following formula
1 ,𝑛 = 0
𝑓 𝑛 = ቐ2 ,𝑛 = 1
𝑛 ∗ 𝑛 + 𝑓 𝑛 − 1 + 𝑓 𝑛 − 2 ,𝑛 > 1
• Test your method with n = 7. Display the value returned after each
method call.
Exercise 2
Tracing of Euclidean Algorithm
• Greatest Common Divisor of any
given pair of numbers can be
determined using Euclidean
Algorithm.
• Define the method GCD to find the
greatest common divisor of any two
input number. Greatest Common Divisor of
• Test your method 78 & 66