Click to like/follow us on:
If you have not studied problem solving and algorithm development you are advise do to so before jumping into this examples. However if you fill comfortable you can continue.

Example One:
Write an algorithm that will request for the length and width of a room/house, the algorithm will calculate and display the area of the room.
Premise:

The question required us to develop this algorithm in such a way that it will request for length & width before calculation of the area of the room will take place. It means that the algorithm/designer of the algorithm don’t know the area and width of the said room ab initio, in other word it can be area of any room. So the algorithm we are about to develop should be able to calculate the area of any room.
Solution:


Major Steps
1.    Request Data
2.    Calculate Area
3.    Display Area
Stepwise Refinement
1.    Request Data
        1.1    Request length
        1.2    Request width
2.    Calculate Area
        2.1    Area = length * width
3.    Display Area

Explanation/Discussion:
The major steps list out the steps to be followed and the stepwise refinement breaks/refines the steps further into smaller steps that finally solve the problem.
Step 1. Request Data: The algorithm will need the value of the length and width of the room to calculate its area.
          Step 1.1: Request length, gets the value of the length, and
          Step 1.2: Request width, gets the value of the width
Step 2. Calculate Area: This steps makes/carries out the calculation.
          Step 2.1: Area = length * width: Immediately the algorithm get the value of the length and the width of the said room using step 1.1 and 1.2 above, the area will be assigned to the value of the length and the width so obtained from the request data steps.
Step 3. Display Area: This step display the area of the room so calculated in step 2.

Test the Algorithm:
After development of your algorithm the next thing is to test it. If the algorithm produces the wrong result, then you should study and adjust the algorithm. The above algorithm is straight forward so to test it will not be a problem. However, testing some algorithm will be may be so complex, however design the algorithm chart/table/list to suit the algorithm being develop. The table below shows the test for the example one algorithm.

VariableData/Information/Result
Request length10
Request width3
Area = length * width10 * 3
Display Area30

The image below is the model of the room/house that it area have being calculated. The area may be the area of the whole house as shown in the figure or that of the different rooms in the but excluding bath room, because from all indication bath room is has the shape of a square (i.e Area = length * length).
image
The above algorithm use the linear control structure class of algorithm.

If you get confuse at any of this examples, then leave a comment below.


SHARE THIS POST WITH YOUR FRIENDS...::

0 comments:

Leave a Reply

All Posts

Access all posts here!

Categories

Unordered List

Sample Text

Lists of Jobs in the United States

List of Courses & Outlines For UNN Students

Popular Posts

Like us on Facebook

Recent Posts

    Text Widget