/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q33E Give an efficient algorithm to c... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Give an efficient algorithm to compute the least common multiple of two n-bit numbers x and y, that is, the smallest number divisible by bothx and y. What is the running time of your algorithm as a function of n?

Short Answer

Expert verified

The final time complexity can be written as O(n3).

Step by step solution

01

Introduction

The least common multiple can be defined as the smallest factor of the two numbers and the running time complexity can be defined as the total amount of time taken to complete the process. It generally analyzes the time taken at each step and finally, it computes the final time complexity.

02

Algorithm to compute LCM(x,y)

Consider,LCM(x,y)

Store common multiple of xandy in any variable z.

Check whether the variablez is divisible byx andy , that is, use the algorithm:

While ()

If(z%x==0&z%y==0)

Returnz

Else

z++

LCM(x,y) can be written as(x×y)÷gcd(x,y) .

03

Time complexity of the algorithm

Forx*y the time complexity of that part isO(n2) and to find GCD we need time complexity equal to O(n3). So, final time complexity can be written as O(n3).

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

A d-ary tree is a rooted tree in which each node has at most dchildren. Show that any d-ary tree with n nodes must have a depth ofΩ(lognlogd) .Can you give a precise formula for the minimum depth it could possibly have?

Unlike a decreasing geometric series, the sum of the1,12,13,14,15,..... diverges; that is,∑i=1n1i=∞

It turns out that, for large n , the sum of the first n terms of this series can be well approximated as

∑i=1n1i≈Inn+y

where is natural logarithm (log base e=2.718...) and y is a particular constant 0.57721...... Show that

∑i=1n1i=θ(logn)

(Hint: To show an upper bound, decrease each denominator to the next power of two. For a lower bound, increase each denominator to the next power of 2 .)

Digital signatures, continued.Consider the signature scheme of Exercise 1.45.

(a) Signing involves decryption, and is therefore risky. Show that if Bob agrees to sign anything he is asked to, Eve can take advantage of this and decrypt any message sent by Alice to Bob.

(b) Suppose that Bob is more careful, and refuses to sign messages if their signatures look suspiciously like text. (We assume that a randomly chosen message−that is, a random number in the range{1,...,N-1} is very unlikely to look like text.) Describe a way in which Eve can nevertheless still decrypt messages from Alice to Bob, by getting Bob to sign messages whose signatures look random.

Find the inverse of:.20mod79,3mod62,21mod91,5mod23

Consider the problem of computing x y for given integers x and y: we want the whole answer, not modulo a third integer. We know two algorithms for doing this: the iterative algorithm which performs y − 1 multiplications by x; and the recursive algorithm based on the binary expansion of y. Compare the time requirements of these two algorithms, assuming that the time to multiply an n-bit number by an m-bit number is O(mn).

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.