JMU JMU - Department of Computer Science
Help Tools
Lab: Experimenting with Algorithms (Without Computers)


Instructions: Answer the following questions one at a time. After answering each question, check your answer (by clicking on the check-mark icon if it is available) before proceeding to the next question.

You will be using two different "kinds" of paper for this lab. Be careful not to confuse them. Each time you execute an algorithm, you must use "fresh" pieces of paper.

One kind is for output, contains numbered lines, and looks as follows:

output.png

Each "cell" on each line can contain exactly one character.

The other kind is for storing variables, contains a place for a name and a place for a value, and looks as follows:

variable.png

When generating output, you must always use the normal left-to-right writing "rule" that is used with English. Unless you are told to do so, you should not move down to a new line if you run out of space.

1. Executing Simple Algorithms: This part of the lab will help you understand what an algorithm is, what it means to execute an algorithm, and some of the elements of algorithms.
  1. Execute the algorithm below:

    algorithm "TitleReporter"

      Move your pencil to the left side of line 1.

      Write the characters "Algorithm Development".

    end algorithm

  2. Which of the following is used in TitleReporter?

    Input
    A variable
    Output
    All of the above
    None of the above

    Output
    Expand
  3. Execute the algorithm below:

    algorithm "BadTitleReporter"

      Move your pencil to the right side of line 1.

      Write the characters "Algorithm Development".

    end algorithm

  4. BadTitleReporter has a "bug" (more formally, a fault). Which of the following is the symptom of the "bug"?

    The characters "Algorithm Development" are not written on the paper.
    The word "Algorithm" is spelled incorrectly.
    The characters "Algorithm Development" are irrelevant.
    All of the above
    None of the above

    The characters "Algorithm Development" are not written on the paper. This "bug" results from the fact that if you move your pencil to the right side of the paper and start writing (using the normal left-to-right rule), the characters will be written on the desk.
    Expand
  5. Execute the algorithm below:

    algorithm "CourseReporter"

      Move your pencil to the left side of line 1.

      Write the characters "Algorithm Development".

      Create a "piece of paper" named number (in ink).

      Store the value 0 on the piece of paper named number (in pencil).

      Replace the value 0 on the piece of paper named number with the value 139 (in pencil).

      Move your pencil to column 30 of line 1.

      Write the characters "CS".

      Write the value that is contained on the paper named number.

    end algorithm

  6. Which of the following is used in CourseReporter but not in TitleReporter?

    Input
    A variable
    Output
    All of the above
    None of the above

    A variable
    Expand
  7. Execute the algorithm below:

    algorithm "NameReporter"

      Ask a person sitting near you to tell you her/his name.

      Create a "piece of paper" named name (in ink).

      Store the person's name on the piece of paper named name (in pencil).

      Move your pencil to the left side of line 1.

      Write the characters "Name: ".

      Write the value that is contained on the paper named name.

    end algorithm

  8. Which of the following is used in NameReporter but not CourseReporter?

    Input
    A variable
    Output
    All of the above
    None of the above

    Input
    Expand
  9. Which of the following is true (based on the algorithms above and your execution of them)?

    The paper named number contains a numeric value
    The paper named name contains alphabetic characters
    The algorithms use characters that are literally in the algorithms
    All of the above
    None of the above

    All of the above
    Expand
  10. Execute the algorithm below:

    algorithm "AgeReporter"

      Create a "piece of paper" named myAge (in ink).

      Store your age (in whole years) on the piece of paper named myAge (in pencil).

      Ask a person sitting near you to tell you her/his age (in whole years).

      Create a "piece of paper" named otherAge (in ink).

      Store the person's age on the piece of paper named otherAge (in pencil).

      Create a "piece of paper" named totalAge (in ink).

      Add the value on the piece of paper named otherAge and the value on the piece of paper named myAge.

      Store the result on the piece of paper named totalAge (in pencil).

      Move your pencil to the left side of line 1.

      Write the characters "Combined Age: ".

      Write the value that is contained on the paper named totalAge.

    end algorithm

  11. Which of the following is used in AgeReporter but not CourseReporter?

    A variable
    An arithmetic calculation (or operation)
    Output
    All of the above
    None of the above

    An arithmetic calculation (or operation)
    Expand
2. Executing (More) Complicated Algorithms: This part of the lab will introduce you to some additional elements of algorithms and the execution of more complicated algorithms.
  1. Execute the algorithm below:

    algorithm "OldAgeReporter"

      Create a "piece of paper" named myAge (in ink).

      Store your age (in whole years) on the piece of paper named myAge (in pencil).

      Ask a person sitting near you to tell you her/his age (in whole years).

      Create a "piece of paper" named otherAge (in ink).

      Store the person's age on the piece of paper named otherAge (in pencil).

      Create a "piece of paper" named totalAge (in ink).

      Add the value on the piece of paper named otherAge and the value on the piece of paper named myAge.

      Store the result on the piece of paper named totalAge (in pencil).

      Move your pencil to the left side of line 1.

      If the value that is contained on the paper named totalAge is less than 50 write the characters "Our Prof. is older than us combined!".

    end algorithm

  2. Which of the following is used in OldAgeReporter but not AgeReporter?

    An arithmetic calculation (or operation)
    A condition
    An iteration
    All of the above
    None of the above

    A condition
    Expand
  3. Execute the algorithm below:

    algorithm "LetterCounter"

      Create a "piece of paper" named sentence (in ink).

      Store the characters "Scribble" on the paper named sentence (in pencil).

      Create a piece of paper named count (in ink).

      Store the value 0 in the paper named count (in pencil).

      Put the index finger of the hand you don't write with under the "S" on the paper named sentence.

      Increase the value on the paper named count by 1 (in pencil).

      If there is a character to the right of the one you are currently pointing to, move your index finger to the right by one character, increase the value on the paper named count by 1 (in pencil), and repeat this step.

    end algorithm

  4. Which of the following is used in LetterCounter but not OldAgeReporter?

    An arithmetic calculation (or operation)
    A condition
    An iteration
    All of the above
    None of the above

    An iteration.
    Expand

Copyright 2025