Communication Is Key

You might have noticed that throughout this unit, we’ve been using a particular style and format for presenting each of our algorithms:

1) do the first operation
2) do the second operation
3) if a condition is true...
4) the third operation
5) otherwise...
6) an alternate third operation
7) do the fourth operation
8) repeat 100 times...
9) the fifth operation
10) stop.

This format was chosen specifically to communicate very precise and unambiguous instructions while maximizing its readability. It has a very clear and mostly intuitive structure that has hopefully been easy for you to read, follow, and understand. Unfortunately, it has some drawbacks.

For example, it can tend to be a bit wordy. We might start to abbreviate our wording or drop minor words that aren’t essential for getting the idea across, like articles (a, an, the). Consider these two alternatives.

4) the third operation
4) operation3

One could argue that the second version is just as clear about its intent despite being more concise. Of course, anytime you abbreviate some text or leave out some words, you run the risk of leaving out important information. So the challenge becomes finding the right balance between conciseness and completeness—that is, being brief, but still saying everything you need to say.

This is a major issue when a language developer tries to design a new programming language. As we saw when we discussed high-level and low-level languages, each language has its own particular set of grammatical rules and structures that are designed to allow programmers to clearly communicate everything they need to express with conciseness and precision.

However, when talking about algorithms in general, we’re interested in being able to describe solutions at an extremely high conceptual level without needing to get into the specifics of the grammar of a particular programming language. And that’s where pseudocode comes into play.

"False Code"

We use the term pseudocode to describe any method used to express an algorithm in an informal, language-agnostic manner. Derived from the Greek word pseudes, or “lying, false,” pseudocode refers to a way of writing formal instructions in an informal manner that does not necessarily adhere to the grammatical rules and syntax of any particular language.

Instead, pseudocode aims to mimic the general style of a programming language without worrying about the exact syntax or structure of the language. It’s basically a shorthand way of writing out the details of an algorithm.

In fact, while pseudocode does not have any standard, universal form, most individuals or organizations that need to develop and communicate high-level algorithms will often settle on their own, mutually agreed-upon set of notational conventions that they will use.

AP Computer Science Principles

Having said that, since the College Board does not designate any particular programming language for this course, it has established its own set of pseudocode conventions that it will use on the AP Computer Science Principles exam.