17

Technically, Is there a difference between these two words or can we use them interchangeably? Both of them more or less describe the logical sequence of steps that follow in solving a problem. ain't it? SO why do we actually use two such words if they are meant to talk of the same?

Or, In case if they aren't synonymous words, What is it that differentiates them? In what contexts are we supposed to use the word pseudo code vs the word algorithm?

  • 4
    An algorithm is quicksort. Pseudocode is "Make me a sandwich, then once it's made, bring it to me." – Neil May 20 '11 at 9:58
  • See this answer to another question. There I described a relation between an algorithm and pseudocode. – Goran Jovic May 21 '11 at 13:15
  • 3
    The short version: 'Pseudo code is one of the ways to represent an algorithm' – Goran Jovic May 21 '11 at 13:16
  • 3
    @Neil or even SUDO make me a sandwich xkcd.com/149 – StuperUser Mar 27 '12 at 19:38

11 Answers 11

37

Wikipedia's definition of an Algorithm:

In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning.

Algorithms can be described in various ways, from pure mathematical formulas to complex graphs, more times than not, without pseudocode.

Pseudocode describes how you would implement an algorithm without getting into syntactical details.

So no, they're not really synonymous.

8

An algorithm is an idea about how to write the code. Pseudo code is the written text you need to communicate that idea.

  • Nice! Short and straight. But I'd say "a written text" than "the written text". What do you think? – Luciano Feb 20 at 19:15
6

"Pseudocode" is to "algorithm" as "English" is to "knock-knock joke".

An algorithm is a formal structure for something that might be expressed in pseudocode, or in actual code.

A knock-knock joke is a formal structure for something that might be expressed in English, or in some other language. (Do other cultures do knock-knock jokes? I don't even know.)

  • I don't think so. At least there isn't anything similar in Portuguese about that knock-knock game. So, I'd say that there isn't also in other Romance languages like Spanish and Italian. I won't include French because it had a long affair with English in British islands centuries ago, and I don't know other Romance languages like Romanian and others. – Luciano Feb 20 at 19:27
3

There is only one quicksort algorithm, which is the kind of thing that would exist in Plato's world of pure ideas. There could be any number of different pseudo-code descriptions of it. I think I would define pseudo-code as text that looks roughly like computer code, and could be translated by an experienced programmer into actual computer code without having to make any creative leaps.

So no, I wouldn't use the terms interchangeably.

2

An algorithm is a systematic logical approach used to solve problems in a computer while Pseudocode is the statement in plain English which may be translated later into a programming language (program).

2

An algorithm is the semantic while the pseudo-code is just a syntax of the communication about solving a problem. This means that the algorithm is an actual way a problem is solved while the pseudo-code is just a way of expressing that way.

An algorithm has the same meaning (semantic) if you express it in any way (syntax) be it C programming language, pseudo-code or English language.

1

Pseudo code as i understand is an intermediary between an algorithm and implemented program. You can base your pseudo code on an algorithm. This contains transferable steps to implement.

Algorithm on the other hand implies the overall logic. in sequential steps to solve a problem. if it is represented diagrammatically it is called a flow chart.

Some might refer this to this as pseudo code being a common term in business software development where the client-side Business object developers write pseudo code based on requirements. This is given to a programmer/developer to implement.

Algorithm you would find more common in programing terminology like systems programming,searching,sorting, basically any where there is a complex logic to be implemented.

1

Even though pseudo-code seems closer to code than an algorithm, in practice, pseudo code is less formal and it is a more high level description. For instance you can describe a chess playing computer as a pseudo code like this:

  • place initial pieces in their locations
  • show board
  • while game is not over
    • make move and display board
    • prompt user for move
    • make users move

Yes, this is pseudocode, it is helpful as a good starting point but glosses over lots of details. It does not account for implementation difficulties and variations, but the biggest benefit is that it allows you to conceptualize the whole situation without having to solve all the details.

You can revise it, adding one more level like so:

  • place initial pieces in their locations
  • show board
  • while board is not checkmate or draw
    • make a list of white's legal moves
    • choose the best according to some criteria
    • make that move and compute resulting board
    • see if checkmate or draw has occurred
    • display board
    • make a list of black's legal moves
    • prompt user for legal move for input
    • make that move and compute resulting board
    • see if checkmate or draw has occurred
    • display board

Now you can write pseudocode for each of the major steps like "make a list of black's legal moves", like so:

  • for each black piece
    • for piece type in a given location
      • make a list of next possible locations

Now you can see the power of pseudocode is really in its ability to show the whole situation in one go and then allowing you to address details piece by piece. The weakness is that any step is not a definite simple step.

An algorithm typically picks up one of these steps and details out various data structures in a symbolic language so that you can efficiently meet the goal of the step.

For example, get_legal_moves(board, color) is worthy of an algorithm design:

get_legal_moves(board, color):
    for i,j in board_dimensions
        if piece_at i,j is of color
            if piece type is KNIGHT
                add the following to the next moves list:
                    location i+1 j+2, i-1 j+2... etc
            if piece type is rook
                add locations:....

You can see that the algorithm has to be very precise to be useful.

It ensures several things: that the goals will be met without errors, first and foremost. The steps are very detailed and executable in a mechanized way and that the steps are small enough that you can reorder them to increase the efficiency (speed) with which you finish the task.

  • This appears to be top-down algorithm decomposition expressed in pseudocode at every step. – Nathan Tuggy Jan 16 '16 at 22:01
0

From my experience Pseudo-code has always been written by functional personell (people who own the process) as a way to express the business rules that apply to a process, module or sub-system.

An Algorithm is a difinitive set of logic statements for solving as specific a task as possible.

0

Algorithm is something which is represented in mathematical terms. It includes, analysis, basic implementation (even that's expressed in pseudo code), complexity considerations(best, average and worstcase analysis etc.).

Pseudo code is a human readable representation of a program. Even that can be used to describe an algorithm.

-2

Pseudo means single & code may be an instruction..here Pseudo-code means an statement which is used to understand the computer programing language easily...it helps in Analise the programing code.. . . where as algorithm is an finite logical step of instructions to solve a problem.

  • 1
    this doesn't seem to offer anything substantial over points made and explained in prior 10 answers – gnat Jun 30 '17 at 11:42

protected by gnat Jun 30 '17 at 11:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.