Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

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).

Short Answer

Expert verified

Time complexity of both the algorithms are compared.

Step by step solution

01

Explain Time Complexity

Time complexity is defined as the total amount of time taken to run and complete the function. It is being observed step by step at each statement of the function.Two integers x and y are considered and the exponential is found out by iterative and recursive approach and by comparing their time complexities.

02

Iterative algorithm

Iterative Algorithm is defined as:

defiterative(x,y):Input=x,yOutput=xyFinal=xForiinrange(1,y):Final×=xReturnFinal

Total time complexity of the given algorithm is O(2n).

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 Vaia!

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

Starting from the definition of xymodN(namely, that Ndivides x-y), justify the substitution rule xx'modN,yy'modNx+yx'+y'modN,and also the corresponding rule for multiplication.

Determine necessary and sufficient conditions on xandc so that the following holds: for anya,b, if axbxmodc, thenabmodc .

Alice and her three friends are all users of the RSA cryptosystem. Her friends have public keys (Ni,ei=3),i=1,2,3 where as always,Ni=piqi for randomly chosen n-bit primes piqi. Showthat if Alice sends the same n-bit message M (encrypted using RSA) to each of her friends, then anyone who intercepts all three encrypted messages will be able to efficiently recover M.
(Hint: It helps to have solved problem 1.37 first.)

On page 38, we claimed that since about a 1nfraction of n-bit numbers are prime, on average it is sufficient to draw O(n)random n -bit numbers before hitting a prime. We now justify this rigorously. Suppose a particular coin has a probability p of coming up heads. How many times must you toss it, on average, before it comes up heads? (Hint: Method 1: start by showing that the correct expression isi=1i(1-p)i-1p . Method 2: if E is the average number of coin tosses, show that E=1+(1-p)E).

Suppose that instead of using a compositeN=pqin the RSA cryptosystem (Figure 1.9), we simply use a prime modulus p . As in RSA, we would have an encryption exponent e, and the encryption of a message mmodpwould be memodp.Prove that this new cryptosystem is not secure, by giving an efficient algorithm to decrypt: that is, an algorithm that given and p,e,andmemodp as input, computes . Justify the correctness and analyze the running time of your decryption algorithm.

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.

Sign-up for free