Due: Thursday, Aug. 29, 2012 at noon 50 points.
For this assignment, you will type and submit three (3) algorithms. Make your algorithms clear and concise step-by-step procedures that solve the problems given. I think that each of these should require at least three steps and probably (though, possibly) no more than twenty steps. Think about your answers.
You are to edit a single file in your DFS account using one of the editors that your lab instructor has shown you in your CS 54 lab #1. First though, make a new directory under your home directory and call it cs53 (from home, type mkdir cs53 and enter). Change into that directory (cd cs53). Now, make a new directory under this cs53 directory and name it hw1. Change into that directory and then create the file with your answers in it, naming it something clever like "hw1.txt". The .txt extension is used for files that are nothing but text (not to be compiled). What ever you name that file, make sure it has a .txt extension. This assignment is NOT C++ programming. You are not to compile this. In this (one and only) file (for this assignment), you are to number your answers for the following 3 problems. Also, be sure to put your name and section letter at the top!!
You've graduated from college and you have your first job in industry. Having now secured a very prestigeous job working for the egg producers of greater Northwest Arkansas, you wish to impress your imployer with your scientific accumen. You've been give the task of determining the highest floor of the Eggtromics International sky-scraper in downtown Bentonville, AR, from which an egg can be dropped without breaking on the grass-lawn below. Being a good and faithful employee, you have decided NOT to ask why. Good decision. Thus, you want to know if the 5th floor balconey is the highest floor from which you can drop an egg and have it survive, or is it the 8th, or is the 15th or is the 2nd. Write an algorithm that most efficiently determines this. The building is 99 floors (eggs are important!) and you are given seven eggs (very important)and there is a chupacabra at the bottom so you cannot retrieve the eggs once used (or el chupra will eat you!).
All hens should weigh the same. If one weighs more, then it is an indicator that the hen is eating too much gravel and not enough grain, thus making her an inefficient egg producer. Your job here is to devise a weigh (nice pun, eh?) to determine which single hen in a group of seven hens is the overweight hen. (Note: they all look identical.) Your only tool is a balance. Write an algorithm to do this.
So, now you have another job. You are to travel from farm to farm making sure that the chickens are weighing what the farmers say they weigh. Of course, these chickens you are weighing are done laying eggs and are to be sold as fryers and broilers - to be eaten. The farmers will claim that a chicken weighs some amount, and your job is to verify this claim. Once again, you have a balance, and you have 5 1-lb weights, 1 7-lb weight, and 2 14-lb weights. Write an algorithm that, given a claimed chicken weight, will determine IF you can verify the claimed weight AND which of your weights are required to make that verification. Thus, if a farmer brings you a mondo-chicken and says this here chick weighs 21 pounds, your algorithm will tell you whether or not you can verifiy it and what the combination of weights is. Note: just listing the possible combinations of the weights is an unacceptable answer.
To submit this homework, you are going to use the cssubmit program for your section of cs 53. This assignment will be used for all sections. Your answers should be written up using your favorite editer in a subdirectory called hw1 hanging off your cs53 subdirectory. Remember: make a different directory under cs53 for every one of your assignments. From that directory, at the UNIX command, type "cssubmit 53 a 1" if you are in section a. If you are in section b, type "cssubmit 53 b 1". If you are in section c, type "cssubmit 53 c 1", etc. (Can you see the pattern?) Hit enter. Of course, when submitting homework #2, your last entry in that command should be a 2. Don't type cssubmit 53 a h2or some other variant like that; just the digit 2. Use this scheme for subsequent submissions. If you have any questions about using the editor or submitting, just ask.
NOTE: You can submit the same assignments multiple times. If you submit and then remember something you forgot, you can edit your file, save it, then submit again. The new submission will overwrite the old; we won't see the old one. Time stamps on submissions apply to the latest submission. Always run the submit script from the directory in which the file(s) to be submitted reside(s). Any questions, just ask. Remember, there is a due date/time. Try not to exceed that. If you do, it'll cost you.