Problem solving and Algorithms

Problem Analysis

Problem analysis can be defined as studying a problem to arrive at a satisfactory solution. To solve a problem successfully, the first step is to understand the problem i.e, problem must be understood clearly. Also the problem must be stated clearly and accurately without any confuse. A well-defined problem and clear description of input and output are important for an effective and efficient solution. Study the outputs to be generated so that input can be specified. Design the steps, which will produce the desired result after supplying the input.

If the problem is very complex, split the problem into multiple sub-problems. Solve each sub-problem and combine the solutions of all the sub-problems to at arrive at overall solution to a large problem. This is called divide and conquer technique.

Problem solving steps
  • Understand the problem and plan its logic
  • Construction of the List of Variables
  • Develop an algorithm
  • Refine the algorithm. Refining means making changes
  • Program Development
  • Testing the Program (solution)
  • Validating the Program (solution)
Algorithm

An algorithm is defined as sequence of steps to solve a problem (task). The steps must be finite, well defined and unambiguous. Writing algorithm requires some thinking. Algorithm can also be defined as a plan to solve a problem and represents its logic. Note that an algorithm is of no use if it does not help us arrive at the desired solution

Algorithm characteristics
  1. It should have finite number of steps. No one can be expected to execute infinite number of steps.
  2. The steps must be in order and simple
  3. Each step should be defined clearly stated e. without un-ambiguity
  4. Must include all required information
  5. Should exhibit at least one output

For accomplishing a particular task, different algorithms can be written. Different algorithms can differ in their requirements of time and space. Programmer selects the best suited algorithm for the given task to be solved.

Algorithm for preparing two cups of tea
  1. Add 1.5 cups of water to the vessel
  2. Boil water
  3. Add 2 tea spoons of tea leaves
  4. Add half cup of milk
  5. Add some sugar

Statement 5 is an example of an ambiguous (unclear) statement. This statement doesn’t clearly state the amount of sugar to be added.

Algorithm design
  • Design an algorithm that is easy to understand code and debug. Debugging is the process finding and fixing errors in a program
  • Design an algorithm that makes use of resource such as space (memory) and time efficiently

Gopal Krishna

Hey Engineers, welcome to the award-winning blog,Engineers Tutor. I'm Gopal Krishna. a professional engineer & blogger from Andhra Pradesh, India. Notes and Video Materials for Engineering in Electronics, Communications and Computer Science subjects are added. "A blog to support Electronics, Electrical communication and computer students".

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »