Assignment 01

Due: Wednesday, August 31, 2016 at noon 50 pts.

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 thirty steps. Think about your answers.

To help you out, you will find examples of problems and algorithms to solve those problems HERE. Perhaps reading these examples will help you in devising algorithms for the problems below.

You are to edit a single file in your DFS account using an editor (I like jpico) that your lab instructor has shown you in your CS 1580 lab #1( or #0 depending on who your lab instructor is). First though, make a new directory under your home directory and call it cs1570 (from home, type mkdir cs1570 and enter). Change into that directory (cd cs1570). Now, make a new directory under this cs1570 directory and name it hw1. Change into that directory and then create the file with

  1. 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!!Suppose you have a non-trivial number of students in a room, let's say more than 10. In fact, this is a Calculus problem solving party (Whoooopeeee - S&T party time!). To get into the party, each student puts their student ID into a narrow-necked urn (you can't reach into it) at the door. Now, it's time to leave. Everyone shakes an ID from the urn, but one and only one ID is allowed per student. (You may get yours, but more than likely you have someone else's). Once every student has an ID, each student is only capable of talking with one other student at a time and holding only one ID at a time. (Trading ID's with someone is permissible.) Write an algorithm that the group can use so that all the students leave with their own IDs.

  2. Write an algorithm that will convert a positive integer in base 12 to its equivalent numerical representation in base 10. Now, for you who don't know base representations of numbers, it works like this. We normally count in base 10. Thus, the digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 - ten of them. In base 12, the digits are 0, 1, ..., 9, A, B - twelve of them. For example, 1A212 (that's base 12) is 26610. If this troubles you, then you're normal. But here's some math that will act as a calming agent for your discomfort.

    1. 10312 = 3 x 1 + 0 x 12 + 1x144 = 14710 = 7 x 1 + 4 x 10 + 1 x 100

  3. Assume the following: all the lowercase letters have numeric values 97 through 122, i.e. a=97, b=98, ... , z=122; all the uppercase letters have numeric values 65 through 90, i.e. A=65, ... , Z=90; a special character called the "null character", Ø, has value 0. A word is a contiguous string of non-null letters followed by the null character,Ø. Words are read left to right. Define the lexicographic difference of two words, W1 and W2, to be zero if W1 is identical to W2, otherwise it is the absolute value of the numeric difference of the two letters of W1 and W2 where they first disagree. Examples: W1 is aligator and W2 is alignment so Lex-dif is 13 since n(110) - a(97) = 13. W1 = Align and W2 = align so Lex-dif is 32 since a(97) - A(65) = 32. W1 is bob and W2 is bob so Lex-Dif = 0 since they are identical. W1 is Frank and W2 is Frankenstein so Lex-dif is 101 since e(101) - Ø(0) = 101.

  4. Write an algorithm to compute the lexicographic difference of two words.

To submit this homework, you are going to use the cssubmit program for your section of cs1570. 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 cs1570 subdirectory. Remember: make a different directory under cs1570 for every one of your assignments. From that directory, at the UNIX command, type "cssubmit 1570 a 1" if you are in section a. If you are in section b, type "cssubmit 1570 b 1". If you are in section c, type "cssubmit 1570 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 1570 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.