[Note: this webpage last modified Tuesday, 10-Dec-2013 12:04:28 EST]
Most of my courses (including this one) include programming assignments in C which are turned in on the CS server. For information on setting up the software and handing in assignments, see software and HW.
HW1, due 11:59pm on Aug 27. Complete the Hailstone HOTPO programming contest problem. Your solution should work correctly and be judged as correct by the online judge. Leave your completed code, named hailstone.cpp, in your cs458/handin/ directory. Files with an incorrect filename will receive 0 credit, and note the filename is case sensitive.
As with every HW, make sure
HW2, due 11:59pm on Sep 10. Complete the max-subarray recursive program. You must start with the code we did in class as your starting point. The program should take 3 command line arguments. The first specifies how many numbers go into the list, the second specifies the seed for srand, and the third should be either "fast" or "slow". If the last argument is "slow" the program should run the slow brute-force code we did in class. If the last argument is "fast", it should run the fast divide and conquer algorithm.
The program should output (printf or cout) the optimal value, which is a single number.
Your program should be called maxsubarray.c or maxsubarray.cpp.
A correct program that you can test against is at ~jkinne/public_html/cs458-f2013/code/maxsubarray
HW3 due 11:59pm on Sep 12. Complete the code for 6174 - Pen Counts. It should work properly on the ACM website. If you get a running time error on the ACM website, I might still accept it as good enough. Your program should be called pencount.c or pencount.cpp
HW4 due 11:59pm on Sep 24. Complete a program called bases.cpp or bases.c. The program should take two command line arguments. The first is the base, and the second is a number of digits. The program should print out all numbers in that base that have the specified number of digits. base can be from 1 up to 36. base and digits will be such that base^digits is at most 2^30. There is a correct working program in the usual place on the CS server. Your program output should match that program exactly.
HW5 due 11:59pm on Sep 26. Complete the code for 4533 - Arithmetically Challenged. It should work properly on the ACM website. Your program should be called achallenge.cpp or achallenge.c. There is a correct working program that you can test again in the usual place on the CS server.
HW6 due 11:59pm on Oct 15, 10 points. Rod-cutting problem from book, dynamic programming alg and greedy alg. Use the rodcutting.cpp file in the in-class code as a starting point. It shows what command-line arguments are expected and how the values/prices should be generated. In that file, the p array has the prices for the various lengths. Make sure you use those prices. There is a compiled version that is correct called rodcutting in the in-class code.
HW7 due 11:59pm on Oct 22, 30 points. Fall programming contest problems. Specifications according to the problems statements in the PDF. Test scripts available later. Grading - 10 points for first 3 problems solved. Additional problems solved are extra credit (5 points per problem).
Presentation. Will count for a HW grade, say 30 points. If you come in not prepared, I'll probably stop you at some point and take over (and give you a corresponding low number of points for the HW). You choose a topic, and work with whoever else chooses that topic; or you choose your group and then collectively choose your topic. For each, you should include: examples, what is the running time, what is the algorithm/data structure used for. Choose from the following:
General procedure... Presenters meet with Jeff about 1 week before presentation. Presenters will do the following: at least 2 days before, send out a message of assigned reading, ask 1 quiz question (on paper, it will count for, say, 5 points each day, it should be easy-ish). For the presentation: must do examples, must talk about running time, don't care if PPT or not, programming maybe yes maybe no depending on the topic.
Structure of presentation... 1) What is the problem being solved, with a small example of an instance of the problem and the solution. 2) Say what's the obvious algorithm (e.g., try everything) and how efficient that be. 3) Start talking about whatever better algorithm there is.
Good presentation style... 1) Talk loud enough, look at the audience sometimes. 2) Take pauses, ask questions, and wait to see if people follow.
During presentation, if it's not going well, if it's clear you don't understand and can't explain, then Jeff takes over.
Presentation itself counts for the "project presentation".
Grading: (1) do I think you know the stuff, (2) were you clear about explaining. Each person needs to do part.
Project...
Jeff tells you something you need to implement related to your presentation.
You can code scratch or use other sources (but not other human sources).
Programming language - I don't care. But it has to compile and run on CS.
The code needs to look pretty, be well documented, be easy for your classmates to understand.
You need to have good instructions for how to use it.
There's some due date (right after Thanksgiving break). At that time, I'll give an assignment where everyone in the class needs to use everyone else's programs to solve some simple problems. If your project is not useable at the deadline, it won't be included and you're penalized.
Assignment of projects...
Algorithms fun...
HW project1. You should get done what Jeff discussed with you about your project. If you run into difficulties let him know ASAP. You will get a HW grade worth 15 points for what you have done by Friday, Nov 15. Put your project files in ~cs458xx/handin/project/
Final exam... Includes the first exam as a subset, and all the algorithms we have covered in the second half of the class. For each of the algorithms, you should be able to trace through an example showing the steps of the algorithm and the final solution. You should also know the running time of the algorithm and other key properties (e.g., the approximation factor if it is an approximation algorithm, which types of graphs it works on for shortest path algorithms).
Final exam practice HW, worth 20 HW points and due the day of the final.
Modular exponentiation. Compute the following by hand, showing your work: 2990 mod 999, 315 mod 29
GCD. Compute the following by hand, showing your work: gcd(2022, 1876), gcd(620, 500), 5-1 mod 41
RSA. Choose primes p and q so that 128 < p*q < 256. Use p*q as the n in RSA encryption. Choose also e and d to satisfy the requirements of RSA. Encrypt the message 101 by hand, showing your work.
AVL trees. Insert the following into an AVL tree, in this order, showing your work: 5, 7, 2, 3, 9, 4, 1, 0, 6, 8.
B Trees. Insert the following into a B tree that has parameter t=3, in this order: 5, 7, 11, 2, 3, 10, 9, 4, 1, 12, 0, 6, 8, 13.
Bipartite matching. Use the network flow algorithm to determine a maximal bipartite matching for this graph. Show your work.
Linear programming. A factury manufactures sheets of aluminum and steel, and have 700 square meters of aluminum and 1050 square meeters of steel. The factory can make either trash cans or wagons. A trash can uses 1 square meter of steel and .5 square meters of aluminum, and sells for $20. A wagon uses 1.5 square meters of steel and 1.5 square meters of alumnimum, and sells for $30. The goal is to choose how many trash cans to make and how many wagons to make to maximize profit. Formulate this as a LP, and say what the optimal solution is. Note: assume that the number of trash cans and wagons can be any non-negative real number (so you need to solve an LP, not an ILP).
Euclidean TSP approximation. Consider this graph. First rewrite the graph so that there are edges between all pairs of vertices, and so that each edge is the shortest path between the pairs of vertices. Now give an MST for the graph. Use the MST in the approximation algorithm for TSP to give a TSP on the graph. What is the total weight of the TSP? Is this the optimal TSP?
Huffman code compression. Use Huffman encoding to compress the following text: "this is good. this is good. this is." First list what the frequencies are for each character (include space, digits, punctuation). Use a program to generate that if you like. Then give what the huffman encoding tree is. Then give what the encoding of the text is using the tree. When creating the tree, if there is a tie between two different characters/nodes, always break ties by ASCII-code order (so 'a' with frequency 1 would be considered as "smaller" than 'b' with frequency 1, ' ' is smaller than 'a', etc.).
String matching. Suppose you want to find all occurences of the string "goo" in the text "this is good.". Show how the string matching algorithms naive and Rabin-Karp works to find all occurrences of "goo" in "this is good.".
For the naive algorithm, how many total character comparisons are there?
For Rabin-Karp, use d=128, q=17, and for each character use its ASCII value (e.g., for 'a' use 97). For Rabin-Karp, how many integer comparisons are there (line 10 in the pseudocode in the book), and how many character comparisons are there (line 11 in the book)?