Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
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
1  
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

10 Answers 10

up vote 23 down vote accepted

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.

share|improve this answer

"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.)

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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).

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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