Question: algorithm Help!!! 2. You recall an algorithm from elementary school for factoring a number N: Divide out all factors of 2, then of 3, then
algorithm Help!!!
2. You recall an algorithm from elementary school for factoring a number N: Divide out all factors of 2, then of 3, then of 4, then of 5, then of 6, then of 7, etc. Finally, divide out all factors of N (of which there can be at most one). (a) Write pseudo-code for this algorithm (and print the prime factors). (b) Assume that it takes unit time to add, subtract, multiply, and divide integers. How fast is your algorithm, in order notation, as a function of N? (c) Normally we measure the time for such an algorithm as a function of the size of the input. In this case it is the number of digits in N, rather than the size of N. Assume that N is input as an n-digit binary number. How fast is your algorithm, in order notation, as a function of n? (d) If N is very large, you can no longer assume that arithmetic operations take constant time. Assume that it takes linear time, i.e. O(n) time, to add, subtract, multiply, and divide two n-digit binary numbers. How fast is your algorithm, in order notation, as a function of n (in the worst case)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
