Assignment #3 for Capacity Planning KJC (8/23/01) ----------------------------------- DUE: 10/11 in class Being able to compute prime numbers fast is important for cryptographic applications. The programs prime1.c and prime2.c demonstrate a memory/CPU trade-off. You should instrument the two programs for CPU time and memory consumption. For CPU time you can use the methods of timeit.c. For memory consumption, you really only care about the malloc() size since it will clearly dominate memory consumption for interesting values of N. Do the following: 1) Plot CPU versus N and memory versus N for a single test machine (e.g., for your home PC). 2) Come-up with a heuristic to estimate the CPU time for prime1.c and prime2.c as a function of N for this single test machine. Pick a few values of N and show how close your heuristic is. 3) On what kind of machines might prime2.c to perform worse than prime1.c? 4) The programs have a serious bug in them. See if you can identify it. A "serious bug" is one where a program can give an incorrect result. 5) Can this problem (i.e., that of finding the Nth prime number) be parallelized for better performance? If yes, explain how and explain why it will be faster. HINT: One way to come-up with a heuristic is to use curve-fitting. Excel has a trendline feature the can help with this. A better way to come-up with a heuristic is to have some understanding of the underlying problem (in this case, distribution of prime numbers). EXTRA CREDIT (10 pts): Write a prime3.c that is even faster (by at least 10%) than prime2.c. ---