CSCI 1320 - Assignment #9



This assignment is going to test your abilities to use the things that we have recently discussed in class. This includes dynamic memory, structures, sorting, and searching. After each problem description I've given you sample input and output files as well as my executable which you can save into your sol directory and run on the lab machines (you might have to give the file execute rights though "chmod u+r ???", where ??? is the file name).

As a side note, be sure to save the code from all the programs you do. It is quite possible that later in the semester other assignments will include things that overlap with them and your code will be reusable.

To turn in this assignment just send the code in an e-mail to mlewis@cs.trinity.edu. You can do this with the command "mail mlewis@cs.trinity.edu < assn9.c" if assn9.c is the name of your source file.

Speed Test Problem:

For this assignment I want you to do speed testing on the different sorts that we did. You should write the three sorts (yes, I sent you code, but you should at least try to write them yourself first). You will make two versions of each. One will sort ints like we did in class and the other will sort large structures. The large structures will have one int and an array of 100 doubles. Sorting those will show you the difference of having time consuming copies vs. short copies.

So to get this to work you need to have some numbers to sort. To do this you will use the rand function and fill an array with random numbers. So that your tests are "even" I want you to have one array with 100,000 integers that you fill with random numbers by calling rand. Then have another array of ints and an array of your structures. Copy the ints from your first array into the other arrays and sort them. Do this once using only 100 of the numbers, then 1000, then 10000, and last the full 100000. Use the clock command in time.h to keep track of how long the sorts take. Use man clock to look up the description. Put comments at the top of your submitted code with your results.

For extra credit, think of a way to get data that is partially ordered and use it in the sort and report the results of that. Also, you can plot up the timing results for the 3 sorts on the 4 different input sizes and hand in a paper copy.

Graphics Problem:

One problem that existed in what you did for assignment 7/8 is that while you told it how far the triangles are from you, you didn't use that information for much of anything. Most importantly, you didn't check to see if one triangle was behind another (at least you didn't have to). Now that you know how to sort, you can fix this. I want you to add one more option to your menu. When this option is selected you should sort the triangles based on the point that is closest tot eh viewer (smallest z value). Do this so that when you draw the triangles you draw the ones that are furthest first. That means you want the array to start with the traingle that has the largest z value (again you are only considering the point in the triangle with smallest z-value). This way, when you draw it things will look correct as long as the triangles don't actually intersect one another.

 

Grade Book:

For this you will extend what you did in assignment 7/8 and add sorting to it. I want you to add 3 options (8, 9, and 10 with quit becomeing 11). The first on should just display data for the full class. It should should name, assignment average, quiz average, test average, class participation, and class average. For the second new option is to sort the students alphabetically by their names. This doesn't display anything, it just reorders the students data in the arrays you use. If you select option 8 after doing this all the students will be shown in alphabetical order. The third new option is to sort the students by their class average.