Page 71 - Computer Genius Class 06
P. 71

Advantages of an Algorithm


                 l   Easy to understand.
                 l   Follows a certain protocol.

                 l   A step-by-step explanation of how to solve a certain problem.
                                                                                      Information Literacy
                       Quest                                                          Technology Literacy


                      Write an algorithm to calculate the area of a triangle.

















                 Representation of an Algorithm

                 Algorithm can be represented in two ways:


                                                     Representation of Algorithm





                                          Flowchart                             Pseudocode

                                                                  Begin
                                            Start
                                                                    Input driver's video
                                                                    ClosedEyeCount := 0
                                                                    For every tenth frame in the video Do
                                           Input                     Localize eyes
                                                                     Check status of eyes
                                                                     If eyes are closed Then
                                                                       ClosedEyeCount := ClosedeyeCount + 1
                                                                      Else If eyes are open Then
                                                                       Closed EyeCount := 0
                                                                       End If
                                  Process           Process            If ClosedEyeCount == 3 Then
                                                                         Generate Alarm
                                                                         ClosedEyeCount := 0
                                                                       End If
                                                                     End For
                                            End                   End


                 Flowchart

                    o chart is a diagrammatic representation o  a step  y step plan  hich is  ollo ed to sol e a
                 problem.


                                                                                  Algorithm and Pseudocode    69
   66   67   68   69   70   71   72   73   74   75   76