This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS1010E Programming Methodology Semester 1 2011/2012 Week of 22 – 26 August 2011 Tutorial 1 Suggested Answers Problem Solving Process 1. The problem solving process comprises four phases, namely: analysis , design , imple mentation and testing . We shall illustrate the use of each of these four phases for solving the following problem: Given a piece of rectangular paper, find the largest square that can be used to completely cover the rectangular area without overlaps. You are only allowed to fold and cut the paper. No measurements are to be taken or any calculations performed. (a) Analysis : What is given (input)? What is required (output)? State the specifi cations/constraints of the problem, i.e. what can (or cannot) be done. (b) Design : While adhering to the specifications identified in the analysis phase, we adopt the following design. You may come up with your own design if you wish. Step 1. Rotate the paper such that the height of the paper is longer than its width. Step 2. Begin folding overlapping triangles starting from the top left corner, as shown below. Stop when the remaining portion (shaded) becomes too small. Step 3. If there is no remaining portion, then unfold the overlapped triangle once, and the resulting square is the solution. Step 4. Otherwise, cut out that remaining portion and use it for step 1 again. (c) Implement : Cut out one of the rectangles given in the last page (preferably the one on the right half of the page). Following the above design in order to come up with the largest square as the solution. Do it slowly and carefully to avoidup with the largest square as the solution....
View
Full Document
 Spring '10
 FREUDLEONG
 Math, Remainder, Euclidean algorithm, positive integer, 2012 Week

Click to edit the document details