Algorithms with Selection and Repetition MCQ Practice

Question 1 of 10

A cafeteria worker is writing directions for preparing one lunch tray. Which description is the clearest algorithm that includes a true/false decision?

  1. A. Prepare the tray the right way.
  2. B. If the tray already has a napkin, skip adding another; otherwise place one napkin, then add the sandwich.
  3. C. Make sure every tray looks nice.
  4. D. Use napkins as needed.

Question 2 of 10

A gym locker must be opened before a water bottle is placed inside. If the door does not open, the student waits and tries the combination again until it does, then places the bottle and closes the locker. Which statement is true of this algorithm?

  1. A. Trying the combination until the door opens is repetition; checking whether the door opened is selection.
  2. B. Placing the bottle is repetition because it happens after a decision.
  3. C. Closing the locker is selection because it is the last step.
  4. D. Order does not matter: the bottle can be placed before the locker is opened.

Question 3 of 10

A baker is describing how to finish one ball of dough. Which description uses repetition until an outcome rather than a single fixed action?

  1. A. Add one pinch of salt.
  2. B. Preheat the oven to 375 degrees.
  3. C. Knead, check whether the dough holds a smooth ball, and knead again if it does not, continuing until it does.
  4. D. Place the dough on the counter.

Question 4 of 10

A hiking trail starts at the kiosk. Follow the table exactly. The painted arrow at the fork points downhill. Which sequence is actually followed?

Step Instruction
1 Walk from the kiosk to the fork
2 If the painted arrow points uphill, take the left path; otherwise take the right path
3 Keep walking until you reach a wooden bench
4 Sit on the bench
  1. A. Walk to the fork, take the left path, keep walking until the bench, sit.
  2. B. Walk to the fork, take the right path, keep walking until the bench, sit.
  3. C. Sit on the bench, then walk to the fork.
  4. D. Take the right path without first walking to the fork.

Question 5 of 10

Three beads start left to right: red, tan, navy. Follow these steps in order. (1) If the leftmost bead is red, swap the two rightmost beads; otherwise leave the line unchanged. (2) Repeat "move the leftmost bead to the far right" until the leftmost bead is navy. What is the final order?

  1. A. Red, navy, tan.
  2. B. Navy, tan, red.
  3. C. Tan, red, navy.
  4. D. Navy, red, tan.

Question 6 of 10

Mustard must be spread on the bread before cheese is added, or the cheese will not stick. Procedure P spreads mustard, then adds cheese, then adds tomato. Procedure Q adds tomato, then adds cheese, then spreads mustard. Which statement is correct?

  1. A. P and Q are equivalent because they use the same three ingredients.
  2. B. P follows the required order; Q spreads mustard after the cheese is already placed, so the cheese may not stick.
  3. C. Order never matters in a recipe algorithm.
  4. D. Q is the only valid algorithm because tomato is added first.

Question 7 of 10

A library copier algorithm is: (1) place the page on the glass; (2) if the display shows "jammed", open the side door and clear the paper, then check the display again, repeating until the display does not show "jammed"; (3) press Start; (4) wait until the copy drops into the tray. The display shows "jammed" the first two times it is checked and "ready" the third time. How many times is the side door opened?

  1. A. 0
  2. B. 1
  3. C. 2
  4. D. 3

Question 8 of 10

Which change would turn a valid selection-and-repetition algorithm into instructions that another person cannot follow reliably?

  1. A. Replacing "if the soil is dry, add 100 mL of water; otherwise skip watering" with "water if it seems necessary"
  2. B. Keeping "stir until no lumps remain" as the stopping rule
  3. C. Numbering the steps so they are done in order
  4. D. Stating both the true and false outcomes of a decision

Question 9 of 10

A stage crew follows this algorithm for one music stand: (1) If the stand is folded, unfold it; otherwise leave it. (2) Place the score on the stand. (3) Repeat "nudge the score up 1 cm" until the title is fully visible above the clip. (4) Roll the stand onto the stage. The stand starts unfolded. The title is hidden by 2 cm at first, and each nudge reveals 1 cm. Which statement is true?

  1. A. Step 1 unfolds the stand because every stand must be unfolded.
  2. B. Step 1 takes the "leave it" branch; step 3 nudges twice; rolling happens last.
  3. C. Step 3 is only selection, because the title either is or is not visible.
  4. D. The score can be placed after rolling without changing the result.

Question 10 of 10

A student packs a rain jacket with these instructions: "If the forecast is rain, pack the jacket; otherwise pack nothing extra. Then zip the bag. Keep adjusting the zipper until it closes fully." Which pair correctly names the constructs?

  1. A. Packing the jacket is repetition; zipping is selection.
  2. B. The rain check is selection; adjusting the zipper until it closes is repetition; the steps occur in a required order, so sequencing is also present.
  3. C. All three sentences are selection because each might happen.
  4. D. The algorithm has repetition only, because the zipper might be tried more than once.