0% found this document useful (0 votes)
2 views20 pages

Definition of Algorithm

An algorithm is a set of finite rules or instructions for problem-solving, applicable in fields like computer science, mathematics, and artificial intelligence. It must have characteristics such as clear inputs and outputs, finite steps, and be language-independent. Algorithms can be simple or complex, with various types including brute force, recursive, and dynamic programming, and their efficiency is analyzed through time and space complexity.

Uploaded by

suganya.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views20 pages

Definition of Algorithm

An algorithm is a set of finite rules or instructions for problem-solving, applicable in fields like computer science, mathematics, and artificial intelligence. It must have characteristics such as clear inputs and outputs, finite steps, and be language-independent. Algorithms can be simple or complex, with various types including brute force, recursive, and dynamic programming, and their efficiency is analyzed through time and space complexity.

Uploaded by

suganya.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Definition of Algorithm

The word Algorithm means ” A set of finite rules or instructions


to be followed in calculations or other problem-solving
operations ”
Or
” A procedure for solving a mathematical problem in a finite
number of steps that frequently involves recursive operations”.
Therefore Algorithm refers to a sequence of finite steps to solve
a particular problem.

Use of the Algorithms:


Algorithms play a crucial role in various fields and have many
applications. Some of the key areas where algorithms are used
include:
1. Computer Science: Algorithms form the basis of
computer programming and are used to solve problems
ranging from simple sorting and searching to complex
tasks such as artificial intelligence and machine learning.
2. Mathematics: Algorithms are used to solve
mathematical problems, such as finding the optimal
solution to a system of linear equations or finding the
shortest path in a graph.
3. Operations Research: Algorithms are used to optimize
and make decisions in fields such as transportation,
logistics, and resource allocation.
4. Artificial Intelligence: Algorithms are the foundation of
artificial intelligence and machine learning, and are used
to develop intelligent systems that can perform tasks
such as image recognition, natural language processing,
and decision-making.
5. Data Science: Algorithms are used to analyze, process,
and extract insights from large amounts of data in fields
such as marketing, finance, and healthcare.
These are just a few examples of the many applications of
algorithms. The use of algorithms is continually expanding as
new technologies and fields emerge, making it a vital component
of modern society.
Algorithms can be simple and complex depending on
what you want to achieve.
It can be understood by taking the example of cooking a new
recipe. To cook a new recipe, one reads the instructions and
steps and executes them one by one, in the given sequence. The
result thus obtained is the new dish is cooked perfectly. Every
time you use your phone, computer, laptop, or calculator you are
using Algorithms. Similarly, algorithms help to do a task in
programming to get the expected output.
The Algorithm designed are language-independent, i.e. they are
just plain instructions that can be implemented in any language,
and yet the output will be the same, as expected.
What is the need for algorithms?
1. Algorithms are necessary for solving complex problems
efficiently and effectively.
2. They help to automate processes and make them more
reliable, faster, and easier to perform.
3. Algorithms also enable computers to perform tasks that
would be difficult or impossible for humans to do
manually.
4. They are used in various fields such as mathematics,
computer science, engineering, finance, and many others
to optimize processes, analyze data, make predictions,
and provide solutions to problems.
What are the Characteristics of an
Algorithm?
As one would not follow any written instructions to cook the
recipe, but only the standard one. Similarly, not all written
instructions for programming are an algorithm. For some
instructions to be an algorithm, it must have the following
characteristics:
 Clear and Unambiguous: The algorithm should be
unambiguous. Each of its steps should be clear in all
aspects and must lead to only one meaning.
 Well-Defined Inputs: If an algorithm says to take
inputs, it should be well-defined inputs. It may or may
not take input.
 Well-Defined Outputs: The algorithm must clearly
define what output will be yielded and it should be well-
defined as well. It should produce at least 1 output.
 Finite-ness: The algorithm must be finite, i.e. it should
terminate after a finite time.
 Feasible: The algorithm must be simple, generic, and
practical, such that it can be executed with the available
resources. It must not contain some future technology or
anything.
 Language Independent: The Algorithm designed must
be language-independent, i.e. it must be just plain
instructions that can be implemented in any language,
and yet the output will be the same, as expected.
Properties of Algorithm:
 It should terminate after a finite time.
 It should produce at least one output.
 It should take zero or more input.
 It should be deterministic means giving the same output
for the same input case.
 Every step in the algorithm must be effective i.e. every
step should do some work.
Types of Algorithms:
There are several types of algorithms available. Some important
algorithms are:
1. Brute Force Algorithm:
It is the simplest approach to a problem. A brute force algorithm
is the first approach that comes to finding when we see a
problem.
2. Recursive Algorithm:
A recursive algorithm is based on recursion. In this case, a
problem is broken into several sub-parts and called the same
function again and again.
3. Backtracking Algorithm :
The backtracking algorithm builds the solution by searching
among all possible solutions. Using this algorithm, we keep on
building the solution following criteria. Whenever a solution fails
we trace back to the failure point build on the next solution and
continue this process till we find the solution or all possible
solutions are looked after.
4. Searching Algorithm:
Searching algorithms are the ones that are used for searching
elements or groups of elements from a particular data structure.
They can be of different types based on their approach or the
data structure in which the element should be found.
5. Sorting Algorithm:
Sorting is arranging a group of data in a particular manner
according to the requirement. The algorithms which help in
performing this function are called sorting algorithms. Generally
sorting algorithms are used to sort groups of data in an
increasing or decreasing manner.
6. Hashing Algorithm:
Hashing algorithms work similarly to the searching algorithm.
But they contain an index with a key ID. In hashing, a key is
assigned to specific data.
7. Divide and Conquer Algorithm :
This algorithm breaks a problem into sub-problems, solves a
single sub-problem, and merges the solutions to get the final
solution. It consists of the following three steps:
 Divide
 Solve
 Combine
8. Greedy Algorithm:
In this type of algorithm, the solution is built part by part. The
solution for the next part is built based on the immediate benefit
of the next part. The one solution that gives the most benefit will
be chosen as the solution for the next part.
9. Dynamic Programming Algorithm :
This algorithm uses the concept of using the already found
solution to avoid repetitive calculation of the same part of the
problem. It divides the problem into smaller overlapping
subproblems and solves them.
10. Randomized Algorithm:
In the randomized algorithm, we use a random number so it
gives immediate benefit. The random number helps in deciding
the expected outcome.
To learn more about the types of algorithms refer to the article
about “Types of Algorithms“.
Advantages of Algorithms:
 It is easy to understand.
 An algorithm is a step-wise representation of a solution
to a given problem.
 In an Algorithm the problem is broken down into smaller
pieces or steps hence, it is easier for the programmer to
convert it into an actual program.
Disadvantages of Algorithms:
 Writing an algorithm takes a long time so it is time-
consuming.
 Understanding complex logic through algorithms can be
very difficult.
 Branching and Looping statements are difficult to show
in Algorithms(imp).
How to Design an Algorithm?
To write an algorithm, the following things are needed as a pre-
requisite:
1. The problem that is to be solved by this algorithm i.e.
clear problem definition.
2. The constraints of the problem must be considered
while solving the problem.
3. The input to be taken to solve the problem.
4. The output is to be expected when the problem is
solved.
5. The solution to this problem is within the given
constraints.
Then the algorithm is written with the help of the above
parameters such that it solves the problem.
Example: Consider the example to add three numbers and print
the sum.
Step 1: Fulfilling the pre-requisites
As discussed above, to write an algorithm, its prerequisites must
be fulfilled.
1. The problem that is to be solved by this algorithm:
Add 3 numbers and print their sum.
2. The constraints of the problem that must be
considered while solving the problem: The numbers
must contain only digits and no other characters.
3. The input to be taken to solve the problem: The
three numbers to be added.
4. The output to be expected when the problem is
solved: The sum of the three numbers taken as the
input i.e. a single integer value.
5. The solution to this problem, in the given
constraints: The solution consists of adding the 3
numbers. It can be done with the help of the ‘+’
operator, or bit-wise, or any other method.

Step 2: Designing the algorithm


Now let’s design the algorithm with the help of the above pre-
requisites:
Algorithm to add 3 numbers and print their sum:
1. START
2. Declare 3 integer variables num1, num2, and num3.
3. Take the three numbers, to be added, as inputs in
variables num1, num2, and num3 respectively.
4. Declare an integer variable sum to store the resultant
sum of the 3 numbers.
5. Add the 3 numbers and store the result in the variable
sum.
6. Print the value of the variable sum
7. END

Step 3: Testing the algorithm by implementing it.


To test the algorithm, let’s implement it in C language.
Program:
C++CJavaPythonC#Javascript
// C program to add three numbers
// with the help of above designed algorithm

#include <stdio.h>

int main()
{

// Variables to take the input of the 3 numbers


int num1, num2, num3;

// Variable to store the resultant sum


int sum;

// Take the 3 numbers as input


printf("Enter the 1st number: ");
scanf("%d", &num1);
printf("%d\n", num1);

printf("Enter the 2nd number: ");


scanf("%d", &num2);
printf("%d\n", num2);

printf("Enter the 3rd number: ");


scanf("%d", &num3);
printf("%d\n", num3);

// Calculate the sum using + operator


// and store it in variable sum
sum = num1 + num2 + num3;

// Print the sum


printf("\nSum of the 3 numbers is: %d", sum);

return 0;
}

Output
Enter the 1st number: 0
Enter the 2nd number: 0
Enter the 3rd number: -1577141152

Sum of the 3 numbers is: -1577141152


Here is the step-by-step algorithm of the code:
1. Declare three variables num1, num2, and num3 to store
the three numbers to be added.
2. Declare a variable sum to store the sum of the three
numbers.
3. Use the cout statement to prompt the user to enter the
first number.
4. Use the cin statement to read the first number and store
it in num1.
5. Use the cout statement to prompt the user to enter the
second number.
6. Use the cin statement to read the second number and
store it in num2.
7. Use the cout statement to prompt the user to enter the
third number.
8. Use the cin statement to read and store the third number
in num3.
9. Calculate the sum of the three numbers using the +
operator and store it in the sum variable.
10. Use the cout statement to print the sum of the three
numbers.
11. The main function returns 0, which indicates the
successful execution of the program.
Time complexity: O(1)
Auxiliary Space: O(1)
One problem, many solutions: The solution to an algorithm
can be or cannot be more than one. It means that while
implementing the algorithm, there can be more than one method
to implement it. For example, in the above problem of adding 3
numbers, the sum can be calculated in many ways:
 + operator
 Bit-wise operators
 . . etc
How to analyze an Algorithm?
For a standard algorithm to be good, it must be efficient. Hence
the efficiency of an algorithm must be checked and maintained.
It can be in two stages:
1. Priori Analysis:
“Priori” means “before”. Hence Priori analysis means checking
the algorithm before its implementation. In this, the algorithm is
checked when it is written in the form of theoretical steps. This
Efficiency of an algorithm is measured by assuming that all other
factors, for example, processor speed, are constant and have no
effect on the implementation. This is done usually by the
algorithm designer. This analysis is independent of the type of
hardware and language of the compiler. It gives the approximate
answers for the complexity of the program.
2. Posterior Analysis:
“Posterior” means “after”. Hence Posterior analysis means
checking the algorithm after its implementation. In this, the
algorithm is checked by implementing it in any programming
language and executing it. This analysis helps to get the actual
and real analysis report about correctness(for every possible
input/s if it shows/returns correct output or not), space required,
time consumed, etc. That is, it is dependent on the language of
the compiler and the type of hardware used.
What is Algorithm complexity and how to
find it?
An algorithm is defined as complex based on the amount of
Space and Time it consumes. Hence the Complexity of an
algorithm refers to the measure of the time that it will need to
execute and get the expected output, and the Space it will need
to store all the data (input, temporary data, and output). Hence
these two factors define the efficiency of an algorithm.
The two factors of Algorithm Complexity are:
 Time Factor: Time is measured by counting the number
of key operations such as comparisons in the sorting
algorithm.
 Space Factor: Space is measured by counting the
maximum memory space required by the algorithm to
run/execute.
Therefore the complexity of an algorithm can be divided
into two types:
1. Space Complexity: The space complexity of an algorithm
refers to the amount of memory required by the algorithm to
store the variables and get the result. This can be for inputs,
temporary operations, or outputs.
How to calculate Space Complexity?
The space complexity of an algorithm is calculated by
determining the following 2 components:

 Fixed Part: This refers to the space that is required by


the algorithm. For example, input variables, output
variables, program size, etc.
 Variable Part: This refers to the space that can be
different based on the implementation of the algorithm.
For example, temporary variables, dynamic memory
allocation, recursion stack space, etc.
Therefore Space complexity S(P) of any algorithm P
is S(P) = C + SP(I), where C is the fixed part and S(I) is
the variable part of the algorithm, which depends on
instance characteristic I.
Example: Consider the below algorithm for Linear Search
Step 1: START
Step 2: Get n elements of the array in arr and the number to be
searched in x
Step 3: Start from the leftmost element of arr[] and one by one
compare x with each element of arr[]
Step 4: If x matches with an element, Print True.
Step 5: If x doesn’t match with any of the elements, Print False.
Step 6: END
Here, There are 2 variables arr[], and x, where the arr[] is the
variable part of n elements and x is the fixed part. Hence S(P) =
1+n. So, the space complexity depends on n(number of
elements). Now, space depends on data types of given variables
and constant types and it will be multiplied accordingly.
2. Time Complexity: The time complexity of an algorithm
refers to the amount of time required by the algorithm to
execute and get the result. This can be for normal operations,
conditional if-else statements, loop statements, etc.
How to Calculate, Time Complexity?
The time complexity of an algorithm is also calculated by
determining the following 2 components:
 Constant time part: Any instruction that is executed
just once comes in this part. For example, input, output,
if-else, switch, arithmetic operations, etc.
 Variable Time Part: Any instruction that is executed
more than once, say n times, comes in this part. For

Therefore Time complexity 𝑇(𝑃)


example, loops, recursion, etc.
T(P) of any
algorithm P is T(P) = C + TP(I), where C is the constant
time part and TP(I) is the variable part of the algorithm,
which depends on the instance characteristic I.
Example: In the algorithm of Linear Search above, the time
complexity is calculated as follows:
Step 1: –Constant Time
Step 2: — Variable Time (Taking n inputs)
Step 3: –Variable Time (Till the length of the Array (n) or the
index of the found element)
Step 4: –Constant Time
Step 5: –Constant Time
Step 6: –Constant Time
Hence, T(P) = 1 + n + n(1 + 1) + 1 = 2 + 3n, which can be said
as T(n).

How to express an Algorithm?


1. Natural Language:- Here we express the Algorithm in
the natural English language. It is too hard to understand
the algorithm from it.
2. Flowchart:- Here we express the Algorithm by making
a graphical/pictorial representation of it. It is easier to
understand than Natural Language.
3. Pseudo Code:- Here we express the Algorithm in the
form of annotations and informative text written in plain
English which is very much similar to the real code but as
it has no syntax like any of the programming languages,
it can’t be compiled or interpreted by the computer. It is
the best way to express an algorithm because it can be
understood by even a layman with some school-level
knowledge.
What is PseudoCode: A Complete Tutorial

A Pseudocode is defined as a step-by-step description of an
algorithm. Pseudocode does not use any programming language
in its representation instead it uses the simple English language
text as it is intended for human understanding rather than
machine reading.
Pseudocode is the intermediate state between an idea and
its implementation(code) in a high-level language.

What is the need for Pseudocode


Pseudocode is an important part of designing an algorithm, it
helps the programmer in planning the solution to the problem as
well as the reader in understanding the approach to the problem.
Pseudocode is an intermediate state between algorithm and
program that plays supports the transition of the algorithm into
the program.

Pseudocode is an intermediate state between algorithm and program


How to write Pseudocode?
Before writing the pseudocode of any algorithm the following
points must be kept in mind.
 Organize the sequence of tasks and write the pseudocode
accordingly.
 At first, establishes the main goal or the aim.
Example:
This program will print first N numbers of Fibonacci
series.
 Use standard programming structures such as if-
else, for, while, and cases the way we use them in
programming. Indent the statements if-else, for, while
loops as they are indented in a program, it helps to
comprehend the decision control and execution
mechanism. It also improves readability to a great extent.
Example:
IF “1”
print response
“I AM CASE 1”
IF “2”
print response
“I AM CASE 2”
Use appropriate naming conventions. The human
tendency follows the approach of following what we see. If
a programmer goes through a pseudo code, his approach
will be the same as per that, so the naming must be
simple and distinct.
 Reserved commands or keywords must be represented
in capital letters.
Example: if you are writing IF…ELSE statements then
make sure IF and ELSE be in capital letters.
 Check whether all the sections of a pseudo code are
complete, finite, and clear to understand and
comprehend. Also, explain everything that is going to
happen in the actual code.
 Don’t write the pseudocode in a programming language.
It is necessary that the pseudocode is simple and easy to
understand even for a layman or client, minimizing the
use of technical terms.
Good vs Bad ways of writing Pseudocode:
Good Vs Bad way of writing Pseudocode

Pseudocode Examples:
1. Binary search Pseudocode:
Binary search is a searching algorithm that works only for sorted
search space. It repeatedly divides the search space into half by
using the fact that the search space is sorted and checking if the
desired search result will be found in the left or right half.
Example: Given a sorted array Arr[] and a value X, The task is
to find the index at which X is present in Arr[].
Below is the pseudocode for Binary search.
BinarySearch(ARR, X, LOW, HIGH)
repeat till LOW = HIGH
MID = (LOW + HIGH)/2
if (X == ARR[MID])
return MID

else if (x > ARR[MID])


LOW = MID + 1

else
HIGH = MID – 1
2. Quick sort Pseudocode:
QuickSort is a Divide and Conquer algorithm. It picks an element
as a pivot and partitions the given array around the picked pivot.
Say last element of array is picked as pivot then all elements
smaller than pivot element are shifted on the left side of pivot
and elements greater than pivot are shifted towards the right of
pivot by swapping, the same algorithm is repeatedly followed for
the left and right side of pivot until the whole array is sorted.
Below is the pseudocode for Quick sort
QUICKSORT(Arr[], LOW, HIGH) {
if (LOW < HIGH) {
PIVOT = PARTITION(Arr, LOW, HIGH);
QUICKSORT(ARR, LOW, PIVOT – 1);
QUICKSORT(ARR, PIVOT + 1, HIGH);
}
}
Here, LOW is the starting index and HIGH is the ending index.

Difference between Algorithm and Pseudocode


Algorithm Pseudocode

An Algorithm is used to provide a solution A Pseudocode is a step-by-step


to a particular problem in form of a well- description of an algorithm in code-like
defined step-based form. structure using plain English text.

An algorithm only uses simple English Pseudocode also uses reserved


words keywords like if-else, for, while, etc.

There are certain rules for writing


There are no rules to writing algorithms
pseudocode

It is difficult to understand and interpret It is easy to understand and interpret


Difference between Flowchart and
Pseudocode
Flowchart Pseudocode

A Pseudocode is a step-by-step
A Flowchart is pictorial representation of flow description of an algorithm in code
of an algorithm. like structure using plain English
text.

A Flowchart uses standard symbols for input,


output decisions and start stop statements. Pseudocode uses reserved keywords
Only uses different shapes like box, circle and like if-else, for, while, etc.
arrow.

Pseudocode is better suited for the


Flowcharts are good for documentation
purpose of understanding

1. Infosys Pseudocode Questions:


What will be the output of the following pseudocode?
Question 1) for i=0 to 4 step 1 do
If i==i++ + –i then do
display i
end-if
end-for
Answer: 0
Question 2) Set Character c = ‘7’
switch(c)
case ‘1’: display “One”
case ‘7’: display “Seven”
case ‘2’: display “Two”
default: display “Hello”
break
end-switch
Answer: SevenTwoHello
Question 3) Integer a, p
Set a = 5
a=a+1
a=a*2
a=a/2
p=a/5+6
print p
Answer: 7
Question 4) Integer a, b, c
Set b = 40, a = 20, c = 20
a=a+c
c=c+a
a=a+c
c=c+a
Print a + b + c
Answer: 300
Question 5) Integer a, b, c
Set a = 4, b = 3, c = 1
if (a >> (c – 1) && b << (c + 1))
a=a+c
Else
b = a <<< C
End if
Print a – b + c
Answer: 3
2. Accenture Pseudocode Questions:
What will be the output of the following pseudocode?
Questions 1) What will be the output of the following
pseudocode for a = 5, b = 1?
Integer funn(Integer a, Integer b)
if(b + a || a – b) && (b > a) && 1)
a = a+b+b-2
return 3-a
Else
return a-b+1
End if
return a + b
End function fun()
Answer: 5
Questions 2) What will be the output of the following
pseudocode for a = 5, b = 1?
Integer funn(Integer a, Integer b)
if((b mod a && a mod b) || (a ^ b > a))
a=a ^ b
Else
return a-b
End if
return a + b
End function funn()
Answer: 5
Questions 3) What will be the output of the following
pseudocode?
Integer a, b, c
Set a = 4, b = 4, c = 4
if (a & (b ^ b) & c)
a = a >> 1
End if
Print a + b + c
Answer: 12
Questions 4) What will be the output of the following
pseudocode for a = 10, b = 11?
Integer funn(Integer a, Integer b)
if(0)
return a – b – funn(-7, -1)
End if
a=a+a+a+a
return a
End function funn()
Answer: 40
Questions 5) What will be the output of the following
pseudocode for a = 5, b = 1?
Integer funn(Integer a, Integer b)
if(b + a || a – b) && (b > a) && 1)
a=a+b+b–2
return 3 – a
Else
return a – b + 1
End if
return a + b
End function fun()
Answer: 5
3. Capgemini Pseudocode Questions
What will be the output of the following pseudocode?
Question 1) What will be the output of the following pseudocode
for a=8, b=1?
Integer funn(Integer a, Integer b)
If(a > b && a > 0)
Return a + b + funn (b-1, a-1)
End if
Return a + b
Answer: 16
Question 2) What will be the output of the following pseudocode
for p=7, q=2?
Integer funn(Integer p, Integer q)
if(p + q < 10)
Return 1 + funn(p + 1, q + 1)
Else
Return 2
End if
Answer: 3
Question 3) What will be the output of the following pseudocode
for a=2, b=7, c=7?
Integer funn(Integer a, Integer b, Integer c)
if ((b + a) < (a – b))
a=a+c
b = (10 + 10) + c
End if
Return a + b + c
Answer: 16
Question 4) What will be the output of the following
pseudocode?
String str1 = “err”, str2 = “krr”
Print (count consonant(upper(reverse(str2) + reverse(str1))))
Answer: 5
Question 5) What will be the output of the following pseudo
code?
Integer a, b, c
Set a = 2, b = 11, c = 5
if ((4 + 5) < (6 + b))
b=c&a
End if
Print a + b + c
Answer: 7
PseudoCode Frequently Asked Questions
( FAQ )
1) What are the 5 Rules of pseudocode?
Five important rules for writing pseudocode are:
1. Write one statement per line.
2. Initial keywords should be represented in capital
case(READ, WRITE, IF, WHILE, UNTIL).
3. Indentation of pseudocode should be similar to the actual
program to show hierarchy.
4. Ending the multiline structure is necessary.
5. Keep statements in simple language(English).
2) How do I start pseudocode?
At first, the purpose of the process should be written to make the
aim clear.
3) Is pseudocode easy to learn?
Pseudocode uses plain text mostly written in English language
which makes it easy to understand and present.
4) Why do we use pseudocode?
Pseudocode provides easier understanding to people as
compared to the conventional programming language code that it
is an efficient and platform-independent description of the
important principles of an algorithm.
5) Is pseudocode an algorithm?
Pseudocode is used to represent an algorithm but the structure of
a pseudocode may not follow the same flow as an algorithm is a
well-defined sequence of steps that provides a solution for a given
problem.
6) What is the difference between pseudocode and
flowchart?
A flowchart is a diagrammatic representation that illustrates a
solution model and solution flow to a given problem whereas
Pseudocode is an informal high-level description of the operating
principle of an algorithm.
7) What is the difference between pseudocode and
code?
Pseudocode is just a way to represent the algorithm of the
program, it is how the code would look like when if it is actually
programmed. Source code is the actual code that can be
compiled by the compiler and then be executed by the machine.
8) Which is easier to use algorithm or pseudocode?
Pseudocode is written in English language thus it is easy to
understand, construct and simpler to debug on the other hand
algorithm is quite complex to construct as it sometimes involves
code snippets in it and hence it is a bit difficult when it comes to
debugging algorithm.
9) How do you declare a variable in pseudocode?
In pseudocode Assigning a value to a variable is indicated using
an arrow symbol (←). The arrow points from the value being
assigned towards the variable it is being assigned to.
Example: String ← “GeeksforGeeks”, would be a valid
assignment.
10) What is end if in pseudocode?

To terminate a multiple line if command the endif command is


used. The command can either be specified as two separate
words, ‘end if’ or as a single word, ‘endif’.

Conclusion:
In the above discussion, we understood the importance of
pseudocode in understanding an algorithm. Pseudocode is a lot
simpler to construct and debug as compared to an algorithm.

You might also like