Part 1: What Makes Two Pieces of Code "The Same"?
Part 1: What Makes Two Pieces of Code "The Same"?
Name: (Your first and last name) Course Name: (Name of this course)
Teacher: (Your teacher's name) Date: (MM/DD/YY)
Directions: Follow the prompts and complete the questions on this document. Be sure to do all 5 parts.
Could there ever be two pieces of code that you consider to be “the same” even if they aren’t identical
Explain?
Part 2: Pretend you were in a classroom and wanted to find the answer to these
problems. List the steps you would take to solve each problem below the problem.
Problems:
Find a person whose birthday is before yours: (please use your own words - use complete sentences)
Find a person whose birthday is after yours: (please use your own words - use complete sentences)
Find the person whose birthday is the closest before yours: (please use your own words - use complete
sentences)
Find the person whose birthday is the closest after yours: (please use your own words - use complete
sentences)
Find the person whose birthday is closest to yours: (please use your own words - use complete sentences)
Find the person with an equal number of birthdays before and after theirs: (please use your own words - use
complete sentences)
Find the two people with the closest birthdays in the room: (please use your own words - use complete
sentences)
Find the shortest period of time in which three people have birthdays: (please use your own words - use
complete sentences)
Find the shortest period of time in which four people have birthdays: (please use your own words - use
complete sentences)
Find the longest period of time in which no one has a birthday: (please use your own words - use complete
sentences)
Part 3: Which problems in Part 2 did you need to do something similar in order to solve
them?
Part 4: Decide which of these programs are “the same” as one another. There are six
algorithms.
First pair of algorithms that do exactly the same thing: (please use your own words - use complete sentences)
Second pair of algorithms that do exactly the same thing: (please use your own words - use complete
sentences)
Third pair of algorithms that do exactly the same thing: (please use your own words - use complete sentences)
Algorithm 1 Algorithm 2
Algorithm 1: REPEAT 2 TIMES
{
MOVE_FORWARD()
MOVE_FORWARD()
TURN_RIGHT()
MOVE_FORWARD()
MOVE_FORWARD()
TURN_RIGHT()
TURN_RIGHT()
MOVE_FORWARD()
MOVE_FORWARD()
TURN_RIGHT()
TURN_RIGHT()
}
MOVE_FORWARD()
TURN_RIGHT()
Algorithm 3 Algorithm 4:
moves ← [“F”, “R”, “F”, “R”, “F”, “R”, “F”, “R”]
FOR EACH move IN moves
{
IF (move = “F”)
{
MOVE_FORWARD()
}
ELSE
{
TURN_RIGHT()
}
}
Algorithm 5 Algorithm 6
REPEAT 2 TIMES
{
REPEAT 2 TIMES
{
MOVE_FORWARD()
}
REPEAT 3 TIMES
{
TURN_LEFT()
}
MOVE_FORWARD()
}
Note: AP Psuedocode should always use a monospaced font like "Courier New"