0% found this document useful (0 votes)
10 views3 pages

Recursion and GCD in CSC508 Lab

Uploaded by

Nur Hani Soleha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Recursion and GCD in CSC508 Lab

Uploaded by

Nur Hani Soleha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like