Assignment 1

Part I: Short Answer Questions

This part of the assignment is a crude and blatant attempt to check that you have read over the course information materials, but I hope that writing the answers down will help you to remember some key points from the material in this module. I am not looking for creativity in the answers: feel free to cut and paste from the course notes. In fact, you could think of it as a scavenger hunt for answers in the notes.

  1. How much are the assignments in the course worth?

  2. You have to have finished the course by what date?

  3. You have just over 12 weeks to finish the course so about how many hours a week should you set aside for working on it?

  4. How many modules are there in the course?

  5. According to Brian Kernighan (and your trusty instructor) how is good programming learned? (Be complete.)

  6. Why was Python chosen for this course?

  7. Which of the examinable topics means the least to you right now?

  8. What should computer science really be called?

  9. What are our two key computational resources?

  10. What does the "envelope of algorithm performance" refer to?

  11. What is a computer program?

  12. What is an algorithm?

  13. List the key operations imperative programming relies on.

  14. What are the four functional components of a computer?

  15. How many keywords are there in Python?

  16. Why is the Structured Program Theorem important?

Part II: Using the Python Shell

Use the Python shell to:

Part III: Writing Algorithms

To get some practice specifying algorithms write instructions to enable someone to recreate each of the sugar cube structures pictured below. (N.B. To mark this question I will try and follow your instructions precisely and see how closely the result matches the goal. You might want to give the instructions to a friend and see what they construct before submitting them to me.)

(i). .(ii)
(iii). .(iv)
(v).

Logistics for Parts I to III

Prepare a text file containing,

  1. your answers to the questions form Part I,

  2. the transcript of your Python shell session (including the output!) from Part II, and

  3. your five sets of instructions from Part III.

Send the file to me either,

or,

Part IV: Trading off Processors and Memory

In Big Picture 1: Computer Science you read that algorithms are ranked according to how much space and time (or memory and processing) they use with the goal being to use as little of each as possible. The flipside is that most problems can be solved more quickly the more of each of those resources you have available. We'll demonstrate this in the following exercise (and we'll share our data to confirm it across trials, and perhaps get our competitive juices going). We're going to compare the time it takes to complete some processing depending on how many processors and how much memory we have.

  1. Get a deck of cards and a stopwatch (if not an actual stopwatch, any watch where you can measure time in seconds).

  2. Shuffle the deck of cards.

  3. Time how long it takes you to sort the cards into order* using your hands and a table top (i.e. you can spread the cards out or stack them anyway you want on the table top).

  4. Get three friends and shuffle the deck and time how long it takes the four of you to sort the cards using the tabletop. Give some thought to how you should organize your efforts. (How you do this represents your algorithm.) You might want to do multiple timings here because you will probably be faster the second and third times than the first. After a couple of attempts the rate of your improvement will probably decrease (and you'll be getting bored).

  5. Before your friends flee, shuffle the deck and then time yourselves sorting the cards again but without using the table top, i.e. all the cards have to be held in your eight hands at all times (no placing cards on your kness, head or anywhere else, or holding any in your mouth etc. Although the desire to do these things shows you just how valuable a little more memory can be.).

  6. Now that your friends have left, shuffle the deck and time yourself sorting the deck one last time but this time using only your two hands, i.e. no table top! (Or knees etc.)

Logistics

Post your timing results in the MyYC discussion forum in the following format:

Time:Processors:Memory

where the time should be measured in seconds, the number of processors is the number of hands (either 2 or 8) and the memory is either large (the tabletop) or small (just the built-in memory of the processors) e.g. If it takes you 2 minutes and ten seconds to sort the deck working alone but using the tabletop you would record

130:2:large

One record per line please.

I'll compile all the results once they're available and prepare a graphical summary.


* We'll use Bridge order where the order of the suits will be Clubs-Diamonds-Hearts-Spades and the cards within each suit will be ordered from Ace to King.