Photo by Markus Spiske on Unsplash
Day 4 of my ALX Software Engineering Journey: Algorithm, Pseudocode, Flowchart.
Algorithm:
When you are faced with a challenge, a good way to solve it, is by mapping a set of steps to tackle it and algorithms do just that. Algorithms are logical procedures followed to solve a problem. Algorithms can be represented either using a flowchart or pseudocode.
Flowcharts:
These are diagrammatic representations that use diagrams(usually shapes) to illustrate procedures followed to implement an algorithm. In a flow chart, various shapes indicate various steps and procedures. Some examples are :
- Ellipse: indicates where a process starts or stops.
2 . Parallelogram: indicates input and output into a process.
3. Rectangle: indicates process or steps taken.
4. Arrow: indicates the direction of the flow of ideas.
Here is a flow chart I made to calculate the sum of squares of a given input of numbers.
Pseudocode
Pseudocode: is an informal high-level method of representing an algorithm. In simpler terms it’s just the use of words to describe steps you would take to solve a problem. It is void of syntax but some programmers may decide to implement some syntax from any programming language they are conversant with.
Here is an example of a pseudocode I wrote to calculate the sum of squares of a given input of numbers.
Line 1: I created a variable that will hold the value n
.
Line 2: I created a variable to hold the sum of the squares.
Line 3: I assigned the results of the formula to the variable sumOfSquares
.
Line 4: is the output of the algorithm.
This way I would be able to pick any programming language to implement this algorithm.
Conclusion:
Solving problems are easier if you have an algorithm to follow. Your programming language is just a tool to solve that problem . Problem solving is a skill and routine documentation of algorithms would help you hone that skill.
Thank you for reading my article to the end and if you enjoyed it, please subscribe to my newsletter.