SCRIPTING-AND-PROGRAMMING-FOUNDATIONS practice question 25 of 25

The steps in an algorithm to build a picnic table are given: Measure and mark the lumber cuts that need to be made. Buy the needed materials. Determine the needed materials. Cut the lumber to the proper dimensions. Assemble the pieces and paint.Which two steps of the algorithm should be switched to make the algorithm successful?

Full set: 137 questions
Answer options
A: 1 and 3
B: 1 and 2
C: 2 and 3 Correct answer
D: 2 and 4
Correct Answer:
C. 2 and 3
Explanation

An algorithm requires a precise and logical sequence of steps to be successful. In the given procedure, buying materials (listed as the second step) cannot logically happen before determining what materials are needed (listed as the third step). To correct the algorithm, the step of determining materials must be performed before the step of buying them. Therefore, steps 2 and 3 must be switched.

Why Incorrect

A. Switching 1 and 3 is incorrect. You must determine the materials needed (e.g., lumber) before you can measure and mark them.
B. Switching 1 and 2 is incorrect. You must buy the materials before you can measure and mark them.
D. Switching 2 and 4 is incorrect. You must buy the lumber before you can perform the step of cutting it.

References

1. Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press. Chapter 1.1, "Algorithms," defines an algorithm as a well-defined computational procedure. The correctness of the procedure depends on the proper sequencing of its steps.

2. Sedgewick, R., & Wayne, K. (2011). Algorithms (4th ed.). Addison-Wesley Professional. Section 1.1, "Basic Programming Model," implicitly relies on the sequential execution of statements to define algorithmic processes.

3. MIT OpenCourseWare. (2011). 6.0001 Introduction to Computer Science and Programming in Python, Fall 2016. Lecture 2. The course defines an algorithm as a "sequence of simple steps" and emphasizes the importance of the order of those steps.

Scroll to Top