Addressing a computational problem

Reading time5 min

In brief

Article summary

In this article, you will learn how to transit from a problem, described in natural language, to an algorithm, to a piece of code that solves the problem.

Main takeaways

  • To solve a problem, it is best to formalize it, then specify its solution, and finally code it.

  • Formalizing aims at re-expressing the problem in more adapted terms and concepts.

  • Specifying aims at describing an algorithmic solution using that formalism.

  • Coding translates the algorithm into a program.

Article contents

1 — Video

Please check the video below. You can also read the transcripts if you prefer.

Information

Welcome to this first lesson, in which we will talk about how to deal with a computational problem, and the necessary steps that you should follow to solve it.

The three steps

When faced with a challenging computational problem, it’s sometimes tempting to start programming right away.

While many students might feel like they’re not making progress if they’re not writing lines and lines of code, this just isn’t true. If you wanted to build a house, would you start stacking bricks right away? I don’t think so.

So, each time you’re faced with a computational problem, there are three consecutive steps which should be followed:

  • Formalize.
  • Specify.
  • Code.

Formalize

To formalize means “to express a problem using adapted terminology and concepts”.

In this course, we're going to program an AI to play a game in a maze. So the first step will be to understand how to represent and manipulate mazes.

To do so, we will refer to graph theory, which is a common mathematical framework that helps us to formalize numerous problems.

Programmers that overlook this formalization step are likely to encounter unexpected issues. In simple cases, this could simply delay their work. But in more severe cases it could mean that all the work produced so far is useless, and that they need to start again from scratch.

Specify

Once a problem has been correctly formalized, it’s time to specify a solution.

To specify means "to identify algorithms or methods that are well suited to solve the formalized problem".

For example, in this course, the AI that you will implement will have to move around in the maze. Therefore, we will discuss methods to find a shortest path in a graph. Methods such as this can be used to identify a solution.

Specifying is of paramount importance, and allows us to make the right choices with consideration to the problem at hand.

Specifying also reveals the global structure of the solution, which facilitates team working situations, in that all individuals are aware of exactly what they are expected to do.

Code

Finally, once the problem is specified, it’s time to start coding. Coding should always be the last step in solving a computational problem.

Coding should be quite straight-forward if the formalization and specification steps have been correctly completed, and should follow on smoothly from the specify step.

Concluding words

This concludes today’s lesson. You’ve learnt today that, when developing, it is best not to start coding right away, but to first think a bit about how the problem is formalized, and how a solution is specified.

In the next video, you’ll learn about graph theory. See you soon!

To go further

Important

The content of this section is optional. It contains additional material for you to consolidate your understanding of the current topic.

To go beyond

Important

The content of this section is very optional. We suggest you directions to explore if you wish to go deeper in the current topic.

  • A small presentation of Coq.

    A few words on solutions that exist to prove computer programs, as one would prove a mathematical theorem.