Assignment 01

Due: Thursday, Jan. 29, 2015 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 twenty steps. Think about your answers.

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 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!!

  1. You should all know (in theory, if not in practice) the standard way to shuffle a deck of cards (assume a standard 52 card deck). If you don't, ask some one how to show you how to do it. You are to write an algorithm to emulate this activity perfectly. This means that when you cut the deck in half, the piles are equal in size, and when you merge them together again the interleaving of the cards is a perfect alternating interleaving with the left-hand card falling first. It is said that a deck of cards is "completely shuffled" after 3 such performances. Take this into account!

  2. Here's a game: You have a 20 x 20 grid of letters (A - Z) that can be read up, down, left, right, and on the diagonals. By reading we mean that you can search for english words formed by the randomly scattered letters in the grid. There is known to be a particular word in one of these orientations in the grid. Write an algorithm that describes how to find the word. Assume the word is more than one letter in length.

  3. Write an algorithm that will describe how to subtract a 4-digit integer from another 4-digit integer. Subtracting a larger integer from a smaller integer is not allowed. You may assume that the reader knows how to subtract a 1-digit value from another 1-digit value or 2-digit value (eg. 6-3=3 is understood as would be 15-7=8, etc). (Hint: Begin by referring to the larger as abcd and the smaller as wxyz.)

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.