Assignment 01

Due: Friday, Jan. 31, 2014 at noon

Points Possible: 50 points.

For this assignment, you will type and submit four (4) 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 4 problems. Also, be sure to put your name and section letter at the top!!

  1. You are given a word to find in a dictionary. Your algorithm is to describe how this is done. You can assume the reader (of the algorithm) knows what a book and the alphabet is.

  2. Integer division of two integers a and b, denoted a/b, is the whole number of times b divides a. Exs:

    1. 6/3 = 2 5/2 = 2 4/7 = 0 9/6 = 1 51/9 = ummmm, wait I know this .... 5!

  3. Describe how this is accomplished without the use of regular division or modular arithmetic. Thus, given two integers A and B, how do we obtain the integer quotient A/B ?

  4. In the morning, you are going bunny hunting. The problem is to choose an appropriate gun. Your decision will depend on the type of bunny you are hunting and the weather conditions. Describe how that decision is made given the following parameters:

    • There are 3 kinds of bunnies: porcelain, chocolate, and #4 plastic (ex: Wal Mart type plastic bunny lights). There are two kinds of guns: shotguns and rifles. Weather considerations: temperature and dampness. Considerations:

        • plastic bunnies only come out when it is below 0oC. (freezing) and can only be hunted with a shotgun.

        • chocolate bunnies only come out when it is below 20oC. and can be hunted with either gun.

        • porcelain bunnies come out only if the temperature is above 0oC. and can only be hunted with a rifle.

        • rifles cannot be used if it is raining.

    • You have a window (to see if it is raining) and a thermometer. When you wake in the morning, your mother will inform you of the type of bunny she wants to cook for dinner that night. After you say your prayers that it isn't porcelain or plastic (remember, you have to eat this thing later that night), you need to determine the weapon to take with you.

  1. On your bunny hunting trip, you find a bunny to shoot. In a desparate attempt to save his skin, he offers to play a game with you. If you win, you can shoot him. This is how it works:

    • The bunny randomly chooses a three-digit number. You are supposed to figure out what that number is. You can submit a sequence of guesses to the bunny. The bunny will respond to each of your guesses. The response is also a three-digit number, but comprised of only zero's and one's. For each correct digit in your guess there is a one in the response (in the same location as the correct digit). For each incorrect digit in your guess there is a zero in the response (in the same location as the incorrect digit). For example, if the bunny's secret number is 123 and one of your guesses is 425, you will get the response 010.

  1. You are to write an algorithm that figures out the (secret) number that the bunny picked.

    1. Now, you understand that the bunny can't win. Obviously, this is a . . . dumb bunny.

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 h2 or 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. You can look here for guidance on submitting using the cssubmit command.

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.