Pseudocode

Nicholas An·2020년 8월 18일
0

An algorithm is a step-by-step process designed to achieve some outcome. Computers are the greatest machines ever conceived for doing step-by-step processes.

As a result, the study of algorithms is very closely tied to computers, computer science, and programming.

Normal English sentences may suffice when you want to give specific instructions. Most algorithms that are designed to be run on computers are much, much longer and much complicated. Describing these algorithms in paragraph form would get ambiguous, confusing, and extremely verbose.

Algorithms for making dinner and playing board games are often described in text. This can lead to ambiguity and confusion, which you know if you’ve ever ruined dinner or fought over the rules of a board game.

When humans work with complex processes — especially repetitive processes — they tend to develop specialized ways of communicating. Baseball, knitting, and chess are all examples. In the case of chess, this information

"in the chess game's second move, black's king-side knight moves forward in front of the bishop"

is all described compactly by chess aficionados by writing Nf6.

This chess notation looks almost meaningless to an outsider, but it's still a language designed for humans to communicate. (It's not a computer code, and it's not used in the internal implementation of chess-playing computer programs.)

Pseudocode is the name for the specialized way that computer scientists express algorithms. Fundamentally, pseudocode is just a list of instructions.


This is an example of a command or instruction. These two are also examples of commands:

Algorithms in computer science are almost never just sequences of commands. Algorithms can also include conditional instructions. Here’s an algorithm in English that is conditional on whether the hamster is hiding:

If the hamster is hiding, put on some soothing music. Otherwise, put her ball in the cage and play with her.

Here’s the same algorithm in pseudocode:

profile
Hello, my name is Woo Hyun (Nick) An. My GitHub is https://github.com/nickanism

0개의 댓글