Product Code Database
Example Keywords: kindle fire -final $80-184
barcode-scavenger
   » » Wiki: Pseudocode
Tag Wiki 'Pseudocode'.
Tag

In , pseudocode is a description of the steps in an using a mix of conventions of programming languages (like assignment operator, conditional operator, loop) with informal, usually self-explanatory, notation of actions and conditions.An often-repeated definition of pseudocode since at least 2003 is "a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled natural language" Although pseudocode shares features with regular programming languages, it is intended for reading rather than machine control. Pseudocode typically omits details that are essential for machine implementation of the algorithm, meaning that pseudocode can only be verified by hand.

(2025). 9781665495035
The programming language is augmented with description details, where convenient, or with compact mathematical notation. The reasons for using pseudocode are that it is easier for people to understand than conventional programming language code and that it is an efficient and environment-independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications to document algorithms and in planning of software and other algorithms.

No broad standard for pseudocode syntax exists, as a program in pseudocode is not an executable program; however, certain limited standards exist (such as for academic assessment). Pseudocode resembles skeleton programs, which can be without errors. , and Unified Modelling Language (UML) charts can be thought of as a graphical alternative to pseudocode, but need more space on paper. Languages such as bridge the gap between pseudocode and code written in programming languages.


Application
Pseudocode is commonly used in textbooks and scientific publications related to and numerical computation to describe algorithms in a way that is accessible to programmers regardless of their familiarity with specific programming languages. Textbooks often include an introduction explaining the conventions in use, and the detail of pseudocode may sometimes approach that of formal programming languages.

frequently begin implementing an unfamiliar algorithm by drafting it in pseudocode, then translating it into a programming language while adapting it to fit the larger program. This top-down structuring approach often starts with a pseudocode sketch refined into executable code. Pseudocode is also used in standardization; for example, the MPEG standards rely on formal C-like pseudocode, these standards cannot be understood without grasping the details of the code.


Syntax
Pseudocode generally does not actually obey the rules of any particular language; there is no systematic standard form. Some writers borrow style and syntax from control structures from some conventional programming language, although this is discouraged.
(2025). 9780735619678, Pearson Education.
Invitation to Computer Science, 8th Edition by Schneider/, "Keep statements language independent" as quoted in this stackexchange question Some syntax sources include , Pascal, , C, C++, Java, Lisp, and . Variable declarations are typically omitted. Function calls and blocks of code, such as code contained within a loop, are often replaced by a one-line natural language sentence.

Depending on the writer, pseudocode may therefore vary widely in style, from a near-exact imitation of a real programming language at one extreme, to a description approaching formatted prose at the other.

This flexibility brings both major advantages and drawbacks: on the positive side, no executable programming language "can beat the convenience of inventing new constructs as needed and letting the reader try to deduce their meaning from informal explanations", on the negative, "untested code is usually incorrect".

+ An example of pseudocode (for the mathematical game )
Pascal style:

procedure fizzbuzz;

 for i := 1 to 100 do
   print_number := true;
   if i is divisible by 3 then begin
     print "Fizz";
     print_number := false;
   end;
   if i is divisible by 5 then begin
     print "Buzz";
     print_number := false;
   end;
   if print_number, print i;
   print a newline;
 end
     

C style:

fizzbuzz() {

 for (i = 1; i <= 100; i++) {
   print_number = true;
   if (i is divisible by 3) {
     print "Fizz";
     print_number = false;
   }
   if (i is divisible by 5) {
     print "Buzz";
     print_number = false;
   }
   if (print_number) print i;
   print a newline;
 }
     
}
Python style:

def fizzbuzz():

 for i in range(1,101):
   print_number = true
   if i is divisible by 3:
     print "Fizz"
     print_number = false
   if i is divisible by 5:
     print "Buzz"
     print_number = false
   if print_number: print i
   print a newline
     


Mathematical style pseudocode
In numerical computation, pseudocode often consists of mathematical notation, typically from matrix and , mixed with the control structures of a conventional programming language, and perhaps also descriptions. This is a compact and often informal notation that can be understood by a wide range of mathematically trained people, and is frequently used as a way to describe mathematical . For example, the sum operator (capital-sigma notation) or the product operator (capital-pi notation) may represent a for-loop and a selection structure in one expression:

Normally non- is used for the mathematical equations, for example by means of markup languages, such as or , or proprietary .

Mathematical style pseudocode is sometimes referred to as , for example pidgin (the origin of the concept), pidgin , pidgin , pidgin Pascal, pidgin C, and pidgin Lisp.


Common mathematical symbols
''c'' ← 2π''r'', ''c'' := 2π''r''
''a'' ← ⌊''b''⌋ + ⌈''c''⌉
Logicaland, or
Sums, productsΣ Π''h'' ← Σ<sub>''a''∈''A''</sub> 1/''a''


Example
The following is a longer example of mathematical-style pseudocode, for the Ford–Fulkerson algorithm:

'''algorithm''' ford-fulkerson '''is'''
    '''input:''' Graph ''G'' with flow capacity ''c'',
           source node ''s'',
           sink node ''t''
    '''output:''' Flow ''f'' such that ''f'' is maximal from ''s'' to ''t''
     

    ''(Note that f(u,v) is the flow from node u to node v, and c(u,v) is the flow capacity from node u to node v)''
     

    '''for each''' edge (''u'', ''v'') '''in''' ''G''''E'' '''do'''
        ''f''(''u'', ''v'') ← 0
        ''f''(''v'', ''u'') ← 0
     

    '''while''' there exists a path ''p'' from ''s'' to ''t'' '''in''' the residual network ''G''''f'' '''do'''
        let ''c''''f'' be the flow capacity of the residual network ''G''''f''
        ''c''''f''(''p'') ← min{''c''''f''(''u'', ''v'') | (''u'', ''v'') '''in''' ''p''}
        '''for each''' edge (''u'', ''v'') '''in''' ''p'' '''do'''
            ''f''(''u'', ''v'') ←  ''f''(''u'', ''v'') + ''c''''f''(''p'')
            ''f''(''v'', ''u'') ← −''f''(''u'', ''v'')
     

    '''return''' ''f''
     


Machine compilation of pseudocode style languages

Natural language grammar in programming languages
Several attempts to bring elements of natural language grammar into computer programming have produced programming languages such as , Lingo, , , , and to some extent Python. In these languages, parentheses and other special characters are replaced by prepositions, resulting in quite verbose code. These languages are typically , meaning that variable declarations and other can be omitted. Such languages may make it easier for a person without knowledge about the language to understand the code and perhaps also to learn the language. However, the similarity to natural language is usually more cosmetic than genuine. The syntax rules may be just as strict and formal as in conventional programming, and do not necessarily make development of the programs easier.


Mathematical programming languages
An alternative to using mathematical pseudocode (involving set theory notation or matrix operations) for documentation of algorithms is to use a formal mathematical programming language that is a mix of non-ASCII mathematical notation and program control structures. Then the code can be parsed and interpreted by a machine.

Several formal specification languages include set theory notation using special characters. Examples are:

  • Vienna Development Method Specification Language (VDM-SL).

Some array programming languages include vectorized expressions and matrix operations as non-ASCII formulas, mixed with conventional control structures. Examples are:

  • A programming language (APL), and its dialects APLX and A+.
  • .


See also


Further reading


External links

Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs