A - Pseudocode Conventions
Published online by Cambridge University Press: 05 June 2012
Summary
Rather than presenting the algorithms in this book as programs written in an existing programming language, a pseudocode is used for the formal description of algorithms. Pseudocode is concise and “user-friendly”, where a real program is often obscured by details concerning a rigid syntax.
Pascal-like pseudocode. The pseudocode used in this book very much resembles the language Pascal. An algorithm is usually given as the local algorithm of a process of the system, whose name is used as a subscript to the variables of the program. Process names can be used as array indices, and set variables are used. The variable Neighp is the set of processes to which p is connected (the neighbors of p).
Assignment (“a := expression”), conditional statement (“if conditionthenstatement”, with an optional “elsestatement” part), and loop (“whileconditiondostatement”) are used with the same meaning as in Pascal. The forall statement has the form “forallx ∈ Xdostatement”, where x is a formal parameter and X a set, and means that statement will be executed for each element x of X in turn. The order in which the elements get their turn is not specified, but the s atement is only used where the order does not matter.
- Type
- Chapter
- Information
- Introduction to Distributed Algorithms , pp. 551 - 555Publisher: Cambridge University PressPrint publication year: 2000