Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 31, Problem 1P

(a)

Program Plan Intro

To prove that if both a and b are even, then gcd(a,b)=2×gcd(a2,b2)

(a)

Expert Solution
Check Mark

Explanation of Solution

If a and b are both even, then it can be written that = 2(a2) and b = 2(b2) , such that all the factors stated are integers. Therefore by using BATCHPOLLARDRHO(n,B) ,which states that common factor 2 from both factors can be taken out of the whole function, it can be proved that gcd(a,b)=2×gcd(a2,b2) .

(b)

Program Plan Intro

To prove that if a is odd and b is even, then gcd(a,b)=gcd(a,b2)

(b)

Expert Solution
Check Mark

Explanation of Solution

If b is even and a is odd, then it can be written = 2(b2) , where (b2) is an integer. As, it is known that a is not divisible by 2 (a is odd), the extra factor of 2 which is in b can’t be part of gcd of the given both numbers. It states that gcd(a, b) = gcd(a,b2) . Now imagine = gcd(a, b) . As d is the common divisor, a must be divisible by d , therefore, d shouldn’t contain even factors. Which states that d also divides a and b2 . This states that gcd(a,b)gcd(a,b2) . This inequality holds true even for the reverse procedure. As, the inequalities hold both ways, it results in equality gcd(a,b)=gcd(a,b2) .

(c)

Program Plan Intro

To prove that if both a and b are odd, then gcd(a,b)=gcd(ab2,b)

(c)

Expert Solution
Check Mark

Explanation of Solution

if both a and b are odd, therefore a - b, where a > b is also an odd number. Therefore, gcd(a, b) = gcd( b, b) . Let

  d = gcd(a, b) d'= gcd( b, b) .

Then, there exists n1, n2 such that n1a+n2= d . It can be rewritten as n1(ab)+(n1+n2)b=d . Therefore, dd' . To compute reverse, let n'1a+n'2= d' so that n'1(ab)+n'2b=d' . It can be rewritten as n'1a+(n'2n'1)b=d' , therefore d'd . This means that gcd(a, b) = gcd( b, b) = gcd(b, a  b) . This inequality holds true even for the reverse procedure. As, the inequalities hold both ways, it results in equality. Therefore, gcd(a,b)=gcd(ab2,b) .

(d)

Program Plan Intro

To design an efficient binary gcd algorithm for integers a and b where ab and runs in O(lga) time.

(d)

Expert Solution
Check Mark

Explanation of Solution

  BINARYGCD(a,b)

if a mod 2  1 then

if b mod 2  1 then

return BINARYGCD((  b)2, b)

else return BINARYGCD(a, b2)

end if

else

  if b mod 2  1 then

return BINARYGCD(a2, b)

else

return ×BINARYGCD(a2, b2)

end if

end if

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
23:12 Chegg content://org.teleg + 5G 5G 80% New question A feed of 60 mol% methanol in water at 1 atm is to be separated by dislation into a liquid distilate containing 98 mol% methanol and a bottom containing 96 mol% water. Enthalpy and equilibrium data for the mixture at 1 atm are given in Table Q2 below. Ask an expert (a) Devise a procedure, using the enthalpy-concentration diagram, to determine the minimum number of equilibrium trays for the condition of total reflux and the required separation. Show individual equilibrium trays using the the lines. Comment on why the value is Independent of the food condition. Recent My stuff Mol% MeOH, Saturated vapour Table Q2 Methanol-water vapour liquid equilibrium and enthalpy data for 1 atm Enthalpy above C˚C Equilibrium dala Mol% MeOH in Saturated liquid TC kJ mol T. "Chk kot) Liquid T, "C 0.0 100.0 48.195 100.0 7.536 0.0 0.0 100.0 5.0 90.9 47,730 928 7,141 2.0 13.4 96.4 Perks 10.0 97.7 47,311 87.7 8,862 4.0 23.0 93.5 16.0 96.2 46,892 84.4…
You are working with a database table that contains customer data. The table includes columns about customer location such as city, state, and country. You want to retrieve the first 3 letters of each country name. You decide to use the SUBSTR function to retrieve the first 3 letters of each country name, and use the AS command to store the result in a new column called new_country.  You write the SQL query below. Add a statement to your SQL query that will retrieve the first 3 letters of each country name and store the result in a new column as new_country.
We are considering the RSA encryption scheme. The involved numbers are small, so the communication is insecure.  Alice's public key (n,public_key) is (247,7). A code breaker manages to factories  247 = 13 x 19  Determine Alice's secret key. To solve the problem, you need not use the extended Euclid algorithm, but you may assume that her private key is one of the following numbers 31,35,55,59,77,89.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L