Difference Between Algorithm and Pseudocode

# Difference Between Algorithm and Pseudocode

Vikram Singh
Assistant Manager - Content
Updated on Feb 9, 2024 16:50 IST

An algorithm is a step-by-step procedure for performing a task or solving a problem, whereas pseudocode is an end-to-end description of an algorithm in formal English (or in natural language) to convey the logic of an algorithm. In this article, we will learn the difference between algorithm and pseudocode.

Algorithm and Pseudocode are two important concepts in programming that are quite similar yet differ. Algorithms are set of instructions to solve the problem, while pseudocode is a rough sketch to organize and understand a program before it is written in codes. The key difference between algorithms and pseudocode is that algorithms are more specific, while pseudocodes are more general.

## What is an Algorithm?

An algorithm is a set of instructions or step-by-step procedures for solving problems or performing tasks. These sets of instructions are unambiguous and very well-defined. Now, let’s take an example to get a better understanding.

Example: Find the maximum value in a given list of numbers.

Solutions: Here is a set of instructions (or algorithm) that you can follow to find the maximum value in the list.

1. Start with the first number and assign it as the maximum value.
2. Now, move to the second number; if the second number > the first number, then set the maximum value to the second number; there is no change.
1. i.e., if the current number is greater than the maximum value, then set the maximum value to the current number.
3. Move on to the next number in the list, and repeat step 2 until you have reached the end of the list.
4. The maximum value is the value that was stored in the maximum variable.

Now, let’s try the above sequence of instructions to write a program in Python.

```# algorithm# define a function to find the maximum value in a given list. def find_max(list): maximum = list[0] #setting the first value as the maximum for i in range(len(list)): if list[i] > maximum: # check if the current value is greater than the present maximum value maximum = list[i] # if the current value is greater than the present value setting the current values as the maximum return maximum #define a listl1 = [1, 2, 3, 4, 5, -5, -4.5, -3.5, -2.5, -1.5, 0] #find the maxim value find_max(l1)Copy code```

Output

## What is Pseudocode?

It is a high-level description of an algorithm that uses natural language and simple programming constructs to convey the logic of an algorithm. Pseudocodes are like a special language software developers use to plan an algorithm before writing the code.

In simple terms, it is considered a way or medium to communicate algorithms to other people (or non-programmers) and to document algorithms for future reference.

let’s consider the same example above to find the maximum value from the list.

So, the corresponding pseudo

• Start
• Initialize a variable called “max” to the first element of the list
• Loop through each element of the list
• If the current element is greater than “max”, set “max” equal to the current element
• Continue looping until all elements have been checked
• Output the value of “max”
• Stop

i.e.,

`procedure find_max(list) max = list[0] #initialize a variable for i = 1 to len(list) #loop through each element if list[i] > max max = list[i] #if the current value is greater than max, set max = current value return maxCopy code`

## Conclusion

In this article, we have briefly discussed what algorithms and pseudo code are, the differences between them, and what are the advantages and disadvantages.

Hope you will like the article.

Keep Learning!!

Vikram Singh
Assistant Manager - Content

Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio