Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 47 - CT_AI_Class-5
P. 47

    The Withings Smart Scale tracks weight, body fat, muscle,
                                 and bone, syncing with your phone to monitor health and

                       ai          display progress. It recognises up to 8 family members
                                                    and offers health tips.

                          lens

                     DEBUGGING SIMPLE PROBLEMS

                     Sometimes, algorithms do not give the expected results. This may happen because
                     of mistakes in the algorithm. These mistakes are called bugs. Finding and correcting

                     these mistakes is called debugging.

                     Common Causes of Bugs

                     Bugs happen for many reasons. Here are the most common ones:

                       A step is missing from the algorithm.

                       Steps are written in the wrong order.

                       A decision has the wrong condition (e.g., YES and NO are swapped).

                       The instructions are not clear.

                     Example:

                     Wrong Algorithm for Drinking Milk:                           Correct Algorithm:

                     1.  Drink milk.                                              1.  Pour milk into a glass.
                     2.  Pour milk into glass.                                    2.  Drink the milk.

                                                                Ask
                                                                          AGENT
                                                           OrangeAI
                      Find out when the term bug was first used to mean a mistake.
                              Study

                     How to Debug: The Three-Step Method

                     Here is a simple three-step method for debugging any algorithm:

                     1.   READ: Read  every step  carefully, as  if you  are  a  robot  following instructions
                        for the first time.

                     2.  TRACE: Follow  the steps  on paper  and write down what would happen at

                        each stage.

                     3.  FIX: Once you find the mistake, correct it and test the algorithm again.

                                                                                              Algorithmic Thinking    45

| 42 43 44 45 46 47 48 49 50 51 52 |