The following algorithm determines whether a given natural number N is prime: for each integer k...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The following algorithm determines whether a given natural number N is prime: for each integer k from 2 to [√n] do if k | N then return "N is not prime" end if end for return "N is prime" (a) Suppose that checking whether k | N takes time O (log² (N)) time. What is the running time of this algorithm, as a function of N? You do not need to give a proof. (b) Suppose N is given in binary. What is the running time of the algorithm, as a function of the input size? (Hint: The input is simply N in binary, so the input size is just the length of the binary representation of N.) (c) Is this algorithm efficient? Does it run in polynomial time? The following algorithm determines whether a given natural number N is prime: for each integer k from 2 to [√n] do if k | N then return "N is not prime" end if end for return "N is prime" (a) Suppose that checking whether k | N takes time O (log² (N)) time. What is the running time of this algorithm, as a function of N? You do not need to give a proof. (b) Suppose N is given in binary. What is the running time of the algorithm, as a function of the input size? (Hint: The input is simply N in binary, so the input size is just the length of the binary representation of N.) (c) Is this algorithm efficient? Does it run in polynomial time? The following algorithm determines whether a given natural number N is prime: for each integer k from 2 to [√n] do if k | N then return "N is not prime" end if end for return "N is prime" (a) Suppose that checking whether k | N takes time O (log² (N)) time. What is the running time of this algorithm, as a function of N? You do not need to give a proof. (b) Suppose N is given in binary. What is the running time of the algorithm, as a function of the input size? (Hint: The input is simply N in binary, so the input size is just the length of the binary representation of N.) (c) Is this algorithm efficient? Does it run in polynomial time?
Expert Answer:
Answer rating: 100% (QA)
a The running time of the algorithm as a function of N can be expressed as ON log2N This is becau... View the full answer
Related Book For
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
What is the difference between a market system and a market? How Can you have a market without a market system? Why or why not? How about the other way around? Can you have a market system without a...
-
Because input prices are explained by the forces of supply and demand, it is important to understand how various factors may shift these curves. For each of the following factors that may affect...
-
On December 11, 2007 AT&T announces that it would increase its divided per share by 12.7%. At the same time the company announced a $15.2 billion stock buyback plan. The stock price of AT&T closed up...
-
What is the difference between an accountor and an accountee? Is it important for the needs of both to be taken into account when designing an accounting system? Provide reasons for your view.
-
1. How accurate is Adam Wainwright's analysis of the situation at Guitarras Dominguez? Do you think craftsmanship is incompatible with increasing productivity in this company? Why? 2. What social...
-
Find a news lead and a feature lead that you thought were particularly effective, and a pair of each that were not as good. Post the leads (four total) and write-a few sentences about what separates...
-
PROBLEM 2.60 Two cables tied together at C are loaded as shown. Determine the range of values of P for which both cables remain taut. 300 W 120 lb
-
You will graduate in a few years and start working and it?s never too early to start planning for your retirement and other major financial events. Let?s fast forward to the beginning of your career....
-
A copper container of mass 0.080 kg and specific heat 387 Jkg 1K-1 contains 0.30 kg of water and 0.040 kg of ice at 0C. Steam at 100C is passed into the water and its temperature stabilizes at 20.0C....
-
Who are the major parties involved in this issue? Which market forces have an impact on this issue? How is demand illustrated in this issue? How is supply illustrated in this issue? How has the...
-
TFD, Inc. recently applied for a loan from BNB Credit Union . The large loan received considerable scrutiny, but based on the recommendation of the loan officer and the bank manager it looked like...
-
What is an auditor's evaluation of a statistical sample for attributes when a test of 50 documents results in 3 deviations if the tolerable rate is 7%, the expected population deviation rate is 5%,...
-
A 580-turn solenoid is 20 cm long. The current in it is 38 A. A straight wire cuts through the center of the solenoid, along a 3.0-cm diameter. This wire carries a 28-A current downward (and is...
-
1. For the L-shaped beam below (beam width is 0.5 in), calculate a) Moments of inertia Iyy, Izz and Iyz, b) Angle of rotation Op to the principle axes of inertia; c) Moments of inertia in the...
-
Chloroplasts are illuminated until the levels of the Calvin cycle intermediates reach a steady state. The light is then turned off. How does the level of RuBP vary after this point?
-
Reconsider Problem 9.4. Warren Buffy decides that Bayes' decision rule is his most reliable decision criterion. He believes that 0.1 is just about right as the prior probability of an improving...
-
Weenies and Buns is a food processing plant that manufactures hot dogs and hot dog buns. They grind their own flour for the hot dog buns at a maximum rate of 200 pounds per week. Each hot dog bun...
-
Read the referenced article that fully describes the management science study summarized in the application vignette presented in Section 6.1. Briefly describe how the model for a special type of...
-
The following case deals with the problem of measuring the DTA and the related valuation allowance for year 4. The assumptions are as follows: Required Measure the deferred tax accounts and any...
-
The assumptions are as follows: The company has \($3,176\) of taxable income and \($100\) of tax credits for the current year. The \($84\) DTA for \($400\) of operating loss carryforwards was...
-
The following case deals with the recognition of a DTA, a DTL, and the determination of whether a valuation allowance is needed. The basic assumptions and facts are as follows: Required Complete the...
Study smarter with the SolutionInn App