Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a snippet from some pseudocode for a sorting algorithm. In it, the symbol ← is used to denote assignment, for example for the variable done. However, in the while loop the statement done:= false is written. I would assume it is also an assignment statement but I suspect it means somethings else, or perhaps extra, since if not, the ← would have simple be used again.

Algorithm MyAlgorithm(A, n) 
    Input: Array of integer containing n elements 
    Output: Possibly modified Array A

done ← true 
j ← 0
while j ≤ n - 2 do
     if A[j] > A[j + 1] then
        swap(A[j], A[j + 1])
        done:= false
     j ← j + 1
share|cite|improve this question
This appears to be a slip-up in writing the code. At first I thought the arrow may denote "declare + define", whereas := would denote "redefine", but it's clear that j is redefined using the arrow below. In general, := is an assignment in pseudocode; to be honest, I've never seen the arrow in actual pseudocode. – Eric Jan 17 '13 at 17:09
@Eric You should put this as an answer, I think it's as much an answer as it gets. However, I've seen as assignment (and use it myself) quite a lot. As long as people are consistent, it doesn't really matter much, as the given pseudocode obviously isn't. – Pål GD Jan 17 '13 at 17:17
@PålGD Posted it, with an extra reference to Wikipedia. It's worth noting that they do recognize both the arrow and :=, though they mention that := is "more common". – Eric Jan 17 '13 at 17:21
up vote 5 down vote accepted

The use of := in this context appears to be a slip-up from whomever it is who wrote that pseudocode. The initial impression given is that they have different meanings (I thought at first that := was perhaps "redefine", and that was "declare and define"). However, with the use of j ← j + 1 on the line following it, it seems clear that the := was a mistake.

In general, := and = are the most common assignment operators, seemingly in both pseudocode and real code. You may be interested in looking at notations of the assignment operator in various programming languages, which include :=, =, <-, , and many others.

share|cite|improve this answer
Thanks for that, I let my professor know. – CodyBugstein Jan 17 '13 at 17:32

Your Answer


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.