Question: . Q2. [20 marks] A prime number (or a prime) is a natural number greater than 1 that doesn't have other factors but 1 and
![. Q2. [20 marks] A prime number (or a prime) is](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3d8ce3072c_78166f3d8cdadfd8.jpg)

. Q2. [20 marks] A prime number (or a prime) is a natural number greater than 1 that doesn't have other factors but 1 and itself. Given a parameter n, detecting all prime numbers in [2,n] is a fundamental problem. In the following, we will show you two different algorithms implemented by C language. Analyze the time complexity of each one with big-O notation. void algo(int n, int isPrime[]) The array isPrime contains the result. isPrime[i] = 0 : i is not a prime; isPrime[i] = 1 : i is a prime. - Algorithm1 1 2 int i, 3 4 void algo1 (int n, int isPrime[]){ j; for (i =2; i 1), 2), 3j, 4j, are not prime numbers. 1 2 3 = 4 void algo2 (int n, int isPrime []) { int i, j; for (i =2; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
