Given two numbers a and b the least common multiple


Problem: Time Complexity of the Least Common Multiple (LCM) Algorithm

Given two numbers a and b, the least common multiple (lcm) of a and b is the smallest number m such that both a and b are factors of m. For example, lcm(15, 21) = 105 because it is the smallest number that has both 15 and 21 as factors.

Formally, we will work with the following decision problem:

LCM = {a, b, m | lcm(a, b) = m}

• Explain why the following algorithm that decides LCM does not run in polynomial time:

o Check if m is a multiple of a and b; if not reject a, b, m
o For i = 1, 2, . . . , m - 1 do:

If i is a multiple of a and b, a multiple smaller than m was found.

Reject a, b, m.

o If it reached the end of the loop without finding a multiple less than m, accept a, b, m.

• Prove that LCM ∈ P.

The response should include a reference list. One-inch margins, Using Times New Roman 12 pnt font, double-space and APA style of writing and citations.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Given two numbers a and b the least common multiple
Reference No:- TGS03202380

Now Priced at $15 (50% Discount)

Recommended (98%)

Rated (4.3/5)