Hi, I would appreciate help with a problem from my Algorithms class. Thanks!
*1- This is the Euclid algorithm that computes the greatest
common divisor of two non-negative integers a and b assuming
that a > b >= 0.
Euclid(a, b)
if b = 0
then return a
else Euclid(b, a mod b)
Is this algorithm efficient? If so, what is the reason? If not, why not?
Explain your opinion.
*2- Prove that both versions of the knapsack problem possess the optimal
substructure property.
*3- Prove that 3 CNF Satisfiability problem is reducible to the Halting Problem.
1. Yes this algorithm is efficient consider the below methods.:-
The Euclidean Algorithm for finding GCD(A,B) is as follows:
Example:
Find the GCD of 270 and 192
A=192, B=78
A=78, B=36
A=36, B=6
A=6, B=0
So we have shown:
GCD(270,192) = GCD(192,78) = GCD(78,36) = GCD(36,6) = GCD(6,0) = 6
GCD(270,192) = 6
Hi, I would appreciate help with a problem from my Algorithms class. Thanks! *1- This is...