Problem Solving
What is Programming?
Programming is a process of problem-solving.
There are three techniques in problem-solving:
Analyze the problem
Outline the problem requirements
Design steps (algorithm) to solve the problem
What is Algorithm?
Most people assume that the algorithm is the same as logarithm because its phrases are almost the same, but both are very much different. So, what is algorithm? An algorithm is a step-by-step problem-solving process that is finite.
Problem-solving process :
Step-1: Analyze the problem: analyze problems by creating outlines and their requirements, then design steps (algorithm) to solve the problem.
Step-2: Implement the algorithm: Implement the algorithm in code and verify that the algorithm works.
Step-3: Maintenance: use and modify the program if the problem domain changes.
Example
For example, we want to find the perimeter and area of a rectangle. According to the process of problem-solving that has been written above, we have to analyze the problem first,
Problem : Design an algorithm to find the perimeter and area of a rectangle.
Information : The perimeter and area of the rectangle are given by the following formulas:
Perimeter = 2 * (length + width)
Area = length * width
Requirements : Input : Length and width of the rectangle
Output : Perimeter and area of the rectangle
Process : perimeter = ???, area = ???
After that, we can write the algorithm,
Algorithm :
Get the length of the rectangle
Get the width of the rectangle
Find the perimeter using the following equation : perimeter = 2 * (length + width)
Find the area using the following equation: area = length * width
Display the result perimeter and area
Comments