Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Big-O c) [5 marks] Read over function xgcd, which calculates the extended gcd(a, b), below: 1 def xgcd (n, m): sl, so, t1, to, r1,

Big-O

image text in transcribed

c) [5 marks] Read over function xgcd, which calculates the extended gcd(a, b), below: 1 def xgcd (n, m): sl, so, t1, to, r1, ro =0, 1, 1, 0, m, n while ri 0: 2 quotient = r0 // r1 ro, r1 - r1, ro - quotient. ri, ro - quotient * ri s0 , s1 = s1, so - quotient * s1 tO, t1 = t1, t0 - quotient * t1 return (ro, so, to) Let the input size be a. Assume that the loop body, lines 4-7, is 1 "step". Prove that the runtime of xged, RTxged E O(1g a). Hint: Can you show that every two iterations of the loop reduces r0 by at least half

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions