use an algorithm to efficiently calculate all the prime numbers below N. How do you approach this?
Fantastic news! We've Found the answer you've been seeking!
Question:
use an algorithm to efficiently calculate all the prime numbers below N. How do you approach this?
- Quick and Dirty - How do you calculate the prime numbers below 10? 50? 100? Use Excel to try to produce a solution. Count how many additions, subtractions, divisions and multiplications.
- Can we make it more efficient? After you did 2s, do you have to do 4s, 6s, 8s...? How do you track them? Are there any other rules of thumb observations you can see to improve your algorithm?
- What if you were told that division and multiplication are 100 times slower (more expensive) than addition and subtraction? Can that effect your program?
To Do:
- Create a Quick and Dirty pseudocode to solve this problem. *Version 1*
- Copy and paste version one and call it version 2. Modify version 2 in the next step.
- Revisit your code to see if it can be done more efficiently. *Version 2*
- Copy and paste version 2 and call it version 3. Modify version 3 in the next step.
- In a Breakout room with one or two classmates, compare solutions by talking about them. No showing your solution. *Version 3*
- Write the names of the other people in your breakout room.
- What were the observations you had?
- Were there any observations you can apply to your algorithm?
- Critical thinking: how do you measure your algorithms efficiency? We call this a metric.
Related Book For
Posted Date: