For two integers with n and m digits, respectively, in the decimal system, let us assume...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
For two integers with n and m digits, respectively, in the decimal system, let us assume that multiplication, as well as division with remainder, requires O(nm) time, although theoretically faster algorithms are possible. Given an integer p with n digits, we want to test whether p is a prime number. A rather simple algorithm proceeds as follows: Compute p/i for all integers i with 2 ≤ i ≤ [√p]. If some of the p/i is integer then p is not prime, otherwise p is prime. (We remark that this is by far not the smartest algorithm for the problem.) 1.1. Why is this algorithm correct? That is, why is it enough to test factors i up to [p] only? 1.2. How much time does this algorithm need? Express the time in two ways: once as a function of n, and once as a function of p. Give your derivations of the time bounds, not only your final answers. 1.3. How much time do we save compared to the most naive algorithm that tests all factors i = 2, ..., p? Give a clear quantitative statement. 1.4. Is the time of the proposed algorithm polynomial in the input length? Why, or why not? For two integers with n and m digits, respectively, in the decimal system, let us assume that multiplication, as well as division with remainder, requires O(nm) time, although theoretically faster algorithms are possible. Given an integer p with n digits, we want to test whether p is a prime number. A rather simple algorithm proceeds as follows: Compute p/i for all integers i with 2 ≤ i ≤ [√p]. If some of the p/i is integer then p is not prime, otherwise p is prime. (We remark that this is by far not the smartest algorithm for the problem.) 1.1. Why is this algorithm correct? That is, why is it enough to test factors i up to [p] only? 1.2. How much time does this algorithm need? Express the time in two ways: once as a function of n, and once as a function of p. Give your derivations of the time bounds, not only your final answers. 1.3. How much time do we save compared to the most naive algorithm that tests all factors i = 2, ..., p? Give a clear quantitative statement. 1.4. Is the time of the proposed algorithm polynomial in the input length? Why, or why not?
Expert Answer:
Answer rating: 100% (QA)
11 The algorithm is correct because it exhaustively tests potential factors i up to p ensuring t... View the full answer
Related Book For
Posted Date:
Students also viewed these databases 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...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Procter & Gamble just received payment for a large export of Tide in the amount of 275,000 Denmark kroner (DKK). If the exchange rate is $0.1992 CAD per DKK, how many Canadian dollars will...
-
Delgado Manufacturing's sales slumped badly in 2012. For the first time in its history, it operated at a loss. The company's income statement showed the following results from selling 60,000 units of...
-
Consider the upper half of the astroid described by x 2/3 + y 2/3 = a 2/3 , where a > 0 and |x| a. Find the area of the surface generated when this curve is revolved about the x-axis. Use symmetry....
-
"The compressibility factor \(Z\) for all gases is approximately the same at the same reduced temperature and reduced pressure." This is known as the (a) Law of compressibility factor (b) Law of...
-
Kingsfield starts a subsidiary operation in a foreign country on January 1, 2011. The countrys currency is the kumquat (KQ). To start this business, Kingsfield invests 10,000 kumquats. Of this...
-
Program an Excel Spreadsheet to complete a Fixed Payment LoanAmortization Schedule based on the 5 inputs (see 1a below). Thisspreadsheet should work for any scenario chosen using the 5 inputsbelow...
-
Chelsea Bush is an emerging candidate for her partys nomination for President of the United States. She now is considering whether to run in the high-stakes Super Tuesday primaries. If she enters the...
-
This discussion is an opportunity for you to start thinking about the course and its content. It will also provide you with an opportunity to look back at the end of this course and see how your...
-
How does a SWOT analysis guide a communication strategy?
-
What is the difference between a news release and a media kit?
-
What does SWOT stand for? Which SWOT elements consider factors internal to the organization and which elements look at external factors?
-
A three-phase circuit breaker has a \(15.5-\mathrm{kV}\) rated maximum voltage, \(9.0-\mathrm{kA}\) rated short-circuit current, and a 2.67-rated voltage range factor. (a) Determine the symmetrical...
-
How did Dominos capitalize on cities having poorly maintained roads as part of their message strategy?
-
A firm is considering a project that requires an initial investment of $55,000. The project is expected to generate revenues of $80,000 per year for three years. Operating expenses will be 65% of...
-
Eleni Cabinet Company sold 2,200 cabinets during 2011 at $160 per cabinet. Its beginning inventory on January 1 was 130 cabinets at $56. Purchases made during the year were as follows: February . 225...
-
Repeat Exercise 11 using the Jacobi method. In Exercise 11 a. Is the coefficient matrix Strictly diagonally dominant? b. Compute the spectral radius of the Gauss-Seidel matrix T g . c. Use the...
-
Prove that if Q is nonsingular matrix with Qt = Q1, then Q is orthogonal.
-
Let (x0, y0) = (0, 0) and (x1, y1) = (5, 2) be the endpoints of a curve. Use the given guide points to construct parametric cubic Hermite approximations (x(t), y(t)) to the curve, and graph the...
-
A mixture containing \(15 \mathrm{~mol}\) per cent ethane, \(35 \mathrm{~mol}\) per cent propane, and \(50 \mathrm{~mol}\) per cent n-butane is brought to a condition of \(40^{\circ} \mathrm{C}\) at...
-
Ethyl alcohol and hexane form an azeotrope containing \(33.2 \mathrm{~mol}\) per cent ethanol at \(58.7^{\circ} \mathrm{C}\) and \(1 \mathrm{~atm}\) pressure. Determine the van Laar parameters at...
-
n-heptane and toluene form an ideal solution mixture. At \(373 \mathrm{~K}\), their vapour pressures are \(106 \mathrm{kPa}\) and \(74 \mathrm{kPa}\) respectively. Determine the composition of the...
Study smarter with the SolutionInn App