Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Pseudocode
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Mathematical style pseudocode== In [[numerical computation]], pseudocode often consists of [[mathematical notation]], typically from [[matrix (mathematics)|matrix]] and [[set theory]], mixed with the control structures of a conventional programming language, and perhaps also [[natural language]] 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 [[algorithm]]s. 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: {{nowrap|Return <math>\sum_{k\in S} x_k</math>}} Normally non-[[ASCII]] [[typesetting]] is used for the mathematical equations, for example by means of markup languages, such as [[TeX]] or [[MathML]], or proprietary [[formula editor]]s. Mathematical style pseudocode is sometimes referred to as [[pidgin code]], for example ''pidgin [[ALGOL]]'' (the origin of the concept), ''pidgin [[Fortran]]'', ''pidgin [[BASIC]]'', ''pidgin [[Pascal (programming language)|Pascal]]'', ''pidgin [[C (programming language)|C]]'', and ''pidgin [[Lisp (programming language)|Lisp]]''. ===Common mathematical symbols=== <!-- Copied from Wikipedia:WikiProject_Computer_science/Manual_of_style#Algorithms --> {| class="wikitable" ! Type of operation || Symbol || Example |- | Assignment || β or := ||<code>''c'' β 2Ο''r''</code>, <code> ''c'' := 2Ο''r''</code> |- | Comparison || =, β , <, >, β€, β₯ || |- | Arithmetic || +, β, Γ, /, mod || |- | Floor/ceiling || β, β, β, β || <code>''a'' β β''b''β + β''c''β</code> |- | Logical | '''and''', '''or''' | |- | Sums, products | Ξ£ Ξ | <code>''h'' β Ξ£<sub>''a''β''A''</sub> 1/''a''</code> |} ===Example=== The following is a longer example of mathematical-style pseudocode, for the [[FordβFulkerson algorithm]]: <!-- Same example as in Wikipedia:WikiProject_Computer_science/Manual_of_style#Algorithms --> '''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<sub>(u,v)</sub> is the flow from node u to node v, and c<sub>(u,v)</sub> is the flow capacity from node u to node v)'' '''for each''' edge (''u'', ''v'') '''in''' ''G''<sub>''E''</sub> '''do''' ''f''<sub>(''u'', ''v'')</sub> β 0 ''f''<sub>(''v'', ''u'')</sub> β 0 '''while''' there exists a path ''p'' from ''s'' to ''t'' '''in''' the residual network ''G''<sub>''f''</sub> '''do''' let ''c''<sub>''f''</sub> be the flow capacity of the residual network ''G''<sub>''f''</sub> ''c''<sub>''f''</sub>(''p'') β min{''c''<sub>''f''</sub>(''u'', ''v'') | (''u'', ''v'') '''in''' ''p''} '''for each''' edge (''u'', ''v'') '''in''' ''p'' '''do''' ''f''<sub>(''u'', ''v'')</sub> β ''f''<sub>(''u'', ''v'')</sub> + ''c''<sub>''f''</sub>(''p'') ''f''<sub>(''v'', ''u'')</sub> β β''f''<sub>(''u'', ''v'')</sub> '''return''' ''f''
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Pseudocode
(section)
Add topic