Question: a. Write a program to determine if a positive integer, N, is prime. b. In terms of N, what is the worst-case running time of

a. Write a program to determine if a positive integer, N, is prime.

b. In terms of N, what is the worst-case running time of your program? (You should be able to do this in O(√N).)

c. Let B equal the number of bits in the binary representation of N. What is the value of B?

d. In terms of B, what is the worst-case running time of your program?

e. Compare the running times to determine if a 20-bit number and a 40-bit number are prime.

f. Is it more reasonable to give the running time in terms of N or B? Why?

Step by Step Solution

3.46 Rating (172 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Test to see if N is an odd number or 2 and is not divisible by b as... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

1486-C-S-A(265).docx

120 KBs Word File

Students Have Also Explored These Related Algorithms Questions!