CS100 - Assignment 8 (Data structures and algorithms)

(Section 001, Fall 2007)

All the questions carry equal weight.

  1. Explain, in English and with pictures, 3 different sorting algorithms with detailed pseudocode and count the maximum number of comparisons and swaps needed. Remember that you are limited to what computers are limited to (comparing 2 items at a time; possibly swapping items; keeping track of item positions).

  2. Under what circumstances would you want to use an array implementation of a list rather than a linked implementation of a list? Under what circumstances would you want to use a linked implementation of a list rather than an array implementation of a list?

  3. For each of the following, indicate the data-structure that most closely models the scenario AND EXPLAIN WHY. Note, there can be more than one correct answer. If appropriate, be sure to indicate both the data structure (e.g., "queue") and the implementation (e.g. "using arrays").

    1. A tech-support call system, in which calls are answered in the order received.

    2. An online guest book, where people can enter their name and their homepage, and search for their other peoples' homepages. (We want this to handle searches and updates quickly.)

    3. Software to help explore a cave. You enter the coordinates as you go deeper into the cave, and when you're ready to go home the software tells you how to get out. Assume you always trace your path backwards from the way you went in.

    4. Your boss gives you an assignment. Occasionally, before the assignment is done, your boss runs in screaming "This is URGENT!!" and gives you another assignment to do. Once the new assignment is done, you get to work on the previous assignment. Due to gross mismanagement, many new assignments often come in before any of them are done. What structure do you use to model this?

    5. When you look up a word in the dictionary, you often like to read the entries for the words just before and just after the main one. Sometimes, you even insert a new word. Which structure lets you do this easily?

  4. Name three common computer processes (hardware, operating system, etc); one best described by a list, one by a queue, and one by stack.



Gady Agam 2007-10-29