Program Debugging
Print this page

Divide and Conquer method

  • It is a well know algorithm design method.
    • Example: Binary search, quick sort, merger sort.
  • In this method we put printf statements to print values stored in important variables.
  • By looking at these printed values, we can identify regions where program is executing correctly and wrongly.
  • In the bad part of the program, we can put more printf statements to reduce the scope of the bug.
  • In this way, we can zeroing the location of the bug.
  • For example, we reduce the scope of the bug to a function by putting printf statements to check the return value of each function.
  • With in the function we can put printf statements after each major step, operation, or process, to reduce the bug-scope further.
 
Prev