Question
The following algorithm determines whether a given natural number N is prime: for each integer k from 2 to [n] do if k |
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?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
a The running time of the algorithm as a function of N can be expressed as ON log2N This is becau...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Introduction To Management Science A Modeling And Cases Studies Approach With Spreadsheets
Authors: Frederick S. Hillier, Mark S. Hillier
5th Edition
978-0077825560, 78024064, 9780077498948, 007782556X, 77498941, 978-0078024061
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App