1 Introduction

Developing error-free software is very hard. The way we are developing programs causes many errors resulting in an intended functionalities. The word error, or bug, covers a broad range of meanings from incorrect program code to incorrect program execution [1]. An incorrect program code happens due to a syntax error and can be detected and reported by the compilers. In the lab 0, you learned how to remove a syntax error from your program. A program with an incorrect execution, or logical error, is successfully compiled and run, but produces erroneous output during the execution. Logical errors are subtle and generally hard to be detected as a faulty program may behave well for the most inputs, but misbehaves in a rare and particular case.

Eliminating errors, or debugging, consists of three activities: a) localizing the program statement that cause the problem; b) understanding the root of the problem; and c) fixing the problem. One can intuitively approach these activities or follow a systematic method. Using a systematic method, you do not require to be an expert or have a priori knowledge. In the systematic approach, one first observes the input/output of the system causing the failure. Then, he invents a hypothesis to understand what part of the program is exactly making the error. Based on the hypothesis, he makes a prediction. By running experiments, he tests the consistency between the hypothesis and predication. If the experiments do not satisfy the predication, the hypothesis has to be changed. Otherwise, the hypothesis is refined. The last step is repeated until the hypothesis cannot be refined any more. An illustrative example is provided in Section 1.1.

 1.1 Example