Search code examples
pseudocode

<--- and <-> in pseudocode


I am not from cs background and I am trying to make sense of what is used for what. In pseudocode I see a lot of this:

for i <---  1 to n-1 do
j <--- find-Min(A,i,n)
A[j] <-> A[i]
end for 

What are <--- and <-> used to refer to?


Solution

  • <--- means "assign the right-hand side to the left-hand side" (it is somewhat strange to see this used in the for case, as it might easily have been omitted there).

    <-> means "swap". A[j] value is swapped with A[i].

    EDIT:

    It just occurred to me that the first line might be missing i and should instead read:

    for i <---  1 to n-1 do
    

    This becomes a legitimate use case of <--- described above: i is assigned values from 1 to n-1 sequentially, and the loop body (down to end for, which denotes the end of loop) is executed for each of these i values.