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 questionsAn 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.
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.
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.
Keep practicing
Take the free SCRIPTING-AND-PROGRAMMING-FOUNDATIONS practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other SCRIPTING-AND-PROGRAMMING-FOUNDATIONS practice questions
- Question 1Which characteristic distinguishes a markup language from other languages?
- Question 2A program calculates the average miles per gallon given miles traveled and gas consumed H…
- Question 5Which characteristic specifically describes an object-oriented language?
- Question 6Which is one characteristic of an object-oriented language that is not a characteristic o…
- Question 7Which operation should be used to check if the difference of two values is greater than 1?
- Question 9A program allows the user to play a game. At the end of each game, the program asks the u…
