Open In App

How to Use Algorithms to Solve Problems?

Last Updated : 09 Aug, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

An algorithm is a process or set of rules which must be followed to complete a particular task. This is basically the step-by-step procedure to complete any task. All the tasks are followed a particular algorithm, from making a cup of tea to make high scalable software. This is the way to divide a task into several parts. If we draw an algorithm to complete a task then the task will be easier to complete.

The algorithm is used for,

  • To develop a framework for instructing computers.
  • Introduced notation of basic functions to perform basic tasks.
  • For defining and describing a big problem in small parts, so that it is very easy to execute.

Characteristics of Algorithm

  1. An algorithm should be defined clearly.
  2. An algorithm should produce at least one output.
  3. An algorithm should have zero or more inputs.
  4. An algorithm should be executed and finished in finite number of steps.
  5. An algorithm should be basic and easy to perform.
  6. Each step started with a specific indentation like, “Step-1”,
  7. There must be “Start” as the first step and “End” as the last step of the algorithm.

Let’s take an example to make a cup of tea,

Step 1: Start

Step 2: Take some water in a bowl.

Step 3: Put the water on a gas burner.

Step 4: Turn on the gas burner 

Step 5: Wait for some time until the water is boiled. 

Step 6: Add some tea leaves to the water according to the requirement.

Step 7: Then again wait for some time until the water is getting colorful as tea.

Step 8: Then add some sugar according to taste.

Step 9: Again wait for some time until the sugar is melted.

Step 10: Turn off the gas burner and serve the tea in cups with biscuits.

Step 11: End

Here is an algorithm for making a cup of tea. This is the same for computer science problems.

There are some basics steps to make an algorithm:

  1. Start – Start the algorithm
  2. Input – Take the input for values in which the algorithm will execute.
  3. Conditions – Perform some conditions on the inputs to get the desired output.
  4. Output – Printing the outputs.
  5. End – End the execution.

Let’s take some examples of algorithms for computer science problems.

Example 1. Swap two numbers with a third variable 

Step 1: Start

Step 2: Take 2 numbers as input.

Step 3: Declare another variable as “temp”.

Step 4: Store the first variable to “temp”.

Step 5: Store the second variable to the First variable.

Step 6: Store the “temp” variable to the 2nd variable.

Step 7: Print the First and second variables.

Step 8: End

Example 2. Find the area of a rectangle

Step 1: Start

Step 2: Take the Height and Width of the rectangle as input.

Step 3: Declare a variable as “area”

Step 4: Multiply Height and Width

Step 5: Store the multiplication to “Area”, (its look like area = Height x Width)

Step 6: Print “area”;

Step 7: End

Example 3. Find the greatest between 3 numbers.

Step 1: Start

Step 2: Take 3 numbers as input, say A, B, and C.

Step 3: Check if(A>B and A>C)

Step 4: Then A is greater

Step 5: Print A

Step 6: Else

Step 7: Check if(B>A and B>C)

Step 8: Then B is greater

Step 9: Print B

Step 10: Else C is greater

Step 11: Print C

Step 12: End

Advantages of Algorithm

  • An algorithm uses a definite procedure.
  • It is easy to understand because it is a step-by-step definition.
  • The algorithm is easy to debug if there is any error happens.
  • It is not dependent on any programming language
  • It is easier for a programmer to convert it into an actual program because the algorithm divides a problem into smaller parts.

Disadvantages of Algorithms

  • An algorithm is Time-consuming, there is specific time complexity for different algorithms.
  • Large tasks are difficult to solve in Algorithms because the time complexity may be higher, so programmers have to find a good efficient way to solve that task.
  • Looping and branching are difficult to define in algorithms.

Similar Reads

How to Solve Arithmetic Word Problems?
Arithmetic probably has the longest history during the time. It is a method of calculation that is been in use from ancient times for normal calculations like measurements, labeling, and all sorts of day-to-day calculations to obtain definite values. The term got originated from the Greek word "arithmos" which simply means numbers. Arithmetic is th
4 min read
Google's Photomath App Launched : Solve math problems quickly
Struggling with math problems? Photomath, a revolutionary app from Google, is here to be your personal math tutor. Using your smartphone camera, Photomath instantly scans, solves, and explains a wide range of printed or handwritten math problems, empowering you to understand the "why" behind the answer, not just the "what." In Short: Google’s innov
3 min read
Solve Problems on Mirror and Magnification Formula
Mirror and magnification formulas are fundamental equations used in optics to describe the formation of images by mirrors. These formulas are commonly applied in geometrical optics, which deals with the behavior of light rays using the principles of geometry. This article contains mirror and magnification formula and problems based on it in detail.
8 min read
How to Solve Maths Problems with Google Circle for Students
Math can be a challenging subject for many students. Between understanding word problems and applying the right formulas, getting stuck is a common experience. Google has introduced a powerful tool called Google Circle, designed to help students solve math problems with confidence. Read In Short: What Google Circle is and how it can help students s
5 min read
Solve Linear Equations with Variable on both Sides
Equations contain two types of quantities, one variable the other is number. But we can consider both equivalents for the sake of reverse operations. This is one of the important things that a student must keep in mind for solving various problems. Also, a good understanding of reverse operations would lead to a better level of problem solving. In
4 min read
How to solve a 3 dice problem?
Probability is also known as a possibility. This means math of chance, that trade in the happening of a likely event. The value is designated from zero to one. In math, Probability has been shown to guess how likely events are to occur. Basically, the probability is the scope to which something is to be anticipated to happen. Probability To underst
10 min read
How to solve Equality of Matrices?
The equality of matrices is a mathematical concept where two or more matrices are equal when compared. Before learning the concept of equality of matrices, we need to know what a matrix is. A rectangle or square-shaped array of numbers or symbols organized in rows and columns to represent a mathematical object or one of its attributes is called a m
9 min read
Solve for y in the equation: -1/y = -0.25x2 - 3.5
The concept of algebra taught us how to express an unknown value using letters such as x, y, z, etc. These letters are termed here as variables. this expression can be a combination of both variables and constants. Any value that is placed before and multiplied by a variable is termed a coefficient. An idea of expressing numbers using letters or al
5 min read
Solve (4a<sup>2</sup> - 2a +15) + (a<sup>2</sup> + 3a - 11)
Algebra is the branch of mathematics that deals with the study of numerals and variables. It helps to represent the conditions or problems in the mathematical expressions. Most of the branches of mathematics like calculus, coordinate geometry, etc use algebra. It uses variables like p, q, r, s, and operations like division, subtraction, multiplicat
3 min read
Solve (6 - 3w)(-w2)
The basic concept of algebra taught us how to express an unknown value using letters such as x, y, z, etc. These letters are termed here as variables. this expression can be a combination of both variables and constants. Any value that is placed before and multiplied by a variable is termed as a coefficient. An idea of expressing numbers using lett
4 min read