Question: ( 1 ) ( 4 marks ) Study the smart Sieve algorithm ( we discussed it in our class ) for finding all the prime
marks Study the smart Sieve algorithm we discussed it in our class for finding
all the prime numbers that are smaller or equal to a positive integer bigger than When
index variable i changes, we need to check i i etc., to eliminate them, since we
are sure that i i etc. are not prime numbers. However, we can change the
algorithm such that the first number we need to check is i i This obviously skips some
numbers.
a Argue briefly that this is safe, ie the algorithm is still correct.
b In the notes, we purposely left the upper bound of the algorithm blank. What should it
be Argue that your answer is correct.
marks Use the definition of Onotation to argue that the following statements are
correct.
ann On
bn On
marks Use the definition of Omega notation to argue that the following statements are
correct.
ann Omega n
bnlogn Omega n
marks Use the definition of Theta notation to argue that the following statement is
correct.
nnTheta n
marks Use the definition of Theta notation to prove that, if fnTheta gn and gn
Theta hn then fnTheta hn
marks Solve the following recurrence relations.
a TnTn for n where T
b Tn Tn for n where T
marks Write a recursive algorithm to find the maximum element in an array of n
elements. Analyze its time efficiency.
marks Consider the following algorithm and answer the related questions.
Input: a nonnegative integer n
xyzn
x ;
for i to n do
x x i i
a What does this algorithm compute?
b What are the basic operations in this algorithm?
c What is its time efficiency in terms of the number of basic operations that are
executed?
d Can you improve its time efficiency? Provide your solution.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
