top of page
Writer's pictureD A Rosi Arsida Wardani

Introduction to Algorithms

Problem Solving


 

What is Programming?

Programming is a process of problem-solving.

There are three techniques in problem-solving:

  1. Analyze the problem

  2. Outline the problem requirements

  3. 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 :

  1. Get the length of the rectangle

  2. Get the width of the rectangle

  3. Find the perimeter using the following equation : perimeter = 2 * (length + width)

  4. Find the area using the following equation: area = length * width

  5. Display the result perimeter and area


 

Recent Posts

See All

One-dimensional Arrays

One-dimensional arrays are data structures that contain data types of the same type. In the form of a group of related memories...

Loop

Introduction Examples of algorithms in everyday life : Example 1 : To finish eating a plate of rice (initial conditions) Mouthfuls of a...

Comments


Post: Blog2_Post
bottom of page