Assignment 1

Due by midnight on Sunday, January 21.
Create a file named hw.c in your math211hw directory. This file should be a copy of the "Hello world" program and should print
Hello world.
on the screen and the prompt should appear on the next line. If you want to make sure that I will be able to collect your file, type
Assign1
and hit enter. You should get a message back telling you that your file was found.

Assignment 2

Due by midnight on Monday, January 29.
Copy the Trapezoid rule file (or make your own). Add a section to compute the Simpson's Rule approximation for the same function f(x). Change the print statement so that it prints the Trapezoid Rule approximation, then a tab, then the Simpson's Rule approximation and then a newline. Each number should be floating point, 10 characters wide with 6 characters after the decimal point. You should call your file ts.c. Leave the code for the function to be evaluated as x^3, leave the interval of integration as [0,1] and use 100 subdivisions. Notice that 100 is even so it is an acceptable value for Simpson's Rule.

Assignment 3

Due by midnight on Tuesday, February 13.
Rewrite your ts.c program to conform to the following specifications.
You do not have to write any code for a function unless you wish to test your program. Your code will be graded on how well your program applies the Trapezoid Rule and Simpson's Rule (starting at 0.0 and finishing at 1.0 with 100 steps) to a function that I supply.

If you want to make sure that I will be able to collect your file, type
Assign3
and hit enter. You should get a message back telling you that your file was found.



Assignment 4

Due by midnight on Sunday, February 25.
Add a new operation to your calculator which will clear the stack. We will do (did) the first part in class, namely setting things up so typing the character L clears the stack. Your assignment is to write a function, to be named 'clear_stack'. This function takes no variables as input and returns nothing, but when it returns, the stack should be reset to its initial state. Since this can always be done, there is no need for error messages.

To accomplish this, you will need to modify both your 'stack.c' and 'stack.h' files and these are the two files that will be collected.

If you want to make sure that I will be able to collect your files, type
Assign4
and hit enter. You should get a message back telling you that your files were found.



Assignment 5

Due by midnight on Sunday, March 4.
Add a power operation to your calc.c file. The operation is invoked by '^'. It pops two elements off the stack and raises the second to the first power. Thus
2 3 ^
pops the 3 and then the 2 off the stack and pushes an 8 back on. All that will be collected will be the calc.c file.

You may NOT use the library functions exp or pow. Do not allow negative exponents (this is an integer calculator so the answer is either undefined or 0 anyway). If you get a negative exponent as input, print the error message
"No negative exponents allowed!\n"
and then RESTORE the stack to its state before you tried the power operation.

On Friday March 9 at midnight I will recollect calc.c and regrade it out of 5 points. If your code was fine this time you need do nothing, but if there were issues with your code you should fix them.



Assignment 6

Due by midnight on Tuesday, April 17.
Write the function "stuff_array" and put it in a file called "stuff_array.c". Get the "stuff_array.h" file from our common space via lsdot and copy_file. This function should take an array of pointers already set to the correct size plus a pointer to root and fill in the array so that the array order is the same as the tree order.

As indicated in the declaration, it needs a third variable to tell the function where to put the next pointer and the solution is definitely via recursion.



Assignment 7

Due by midnight on Friday, April 27.
Write a function, "print_in_numerical_order" with declaration

void print_in_numerical_order(WC *root);

which takes a pointer to the root of a WC tree and prints out the entries in the following order: words which occur more often should appear earlier; given several words which occur the same number of times, they should occur in the same order as they do now in the "Word_count" program. The format used for printing should be the same as the one used now by Word_count to print out the answers in alphabetical order.

To do this assignment, first get an up-to-date copy of the Word_count.c file from our common space. The new file is called "WORD_count.c" to distinguish it from various other versions. You need to add to this file the function declaration and the code for the function "print_in_numerical_order" and then call it at the end of "main". You will also need an up-to-date version of "tree_stuff.c" and "tree_stuff.h" in order to compile your program.

"Word_count.c" is the only file that will be collected. I will compile your "WORD_count.c" with the "tree_stuff.c" in our joint space and test the resulting program.

To test your program I recommend you run a big file like "WORD_count.c" through it and see if the order looks right. You might also manufacture a file with several words having the same count to be sure your program handles this case correctly as well.

Hint: The assigned function is not recursive, but you will need to review and write a sort function on an array of pointers. The quick-sort routine can be easily adapted to do this and with a bit more work the shell-sort routine can also be made to work. You may call the sort function you write anything you please and depending on which sort routine you choose to write, you may need to write additional functions.


Back.