Using Flowcharts to Solve Algorithms

Yasmine Hartung
There She Codes
Published in
2 min readJun 5, 2019

Often, when we’re starting a coding project, it is often difficult to break down the problem into elements that we can more easily digest. This makes it difficult to know how and where to being.

A common tool to overcome this initial coders-block is flowcharts for algorithms.

What flowcharts do is allow us to communicate clearly and simply the algorithm for our code. It also helps us break down our solution into simple steps.

There are common shapes used for algorithm flow charts that are usually agreed upon. This is more important if you are working with others and can perhaps help you to write less text on your flow chart.

Thanks smartdraw

Let’s say, for example, that we have a matrix in which we need to find the inner matrix that has the largest sum. The inner matrix can be any size( from 1 element to the whole matrix) and does not necessarily need to be a square.

How would we begin to tackle this problem?

Well, first we know that we start with a matrix, we should sum up all the different kinds of inner matrices and lastly, return the maximum matrix. We can depict that with the following flowchart:

We actually know how to break that middle triangle into three elements: select an inner matrix, sum up that matrix, and then compare the sum of that matrix to the previous maximum. The new flow chart would look like this:

At this point, we can see that each element represents a single functionality of the algorithm. We can choose to go down deeper and elaborate how the inner matrices are selected and how we sum an inner matrix but even just at this higher level, the problem already seems much easier.

This is the advantage of drawing flowcharts for your algorithm. They help you break down the problem before you even begin writing code. This kind of planning can help you write code more efficiently, as you already know what functionality you are expecting from each element.

--

--