3. A question about logic:
On line 21 you do compare two elements of an array. Indices: x and x-1
On the "swap" you look at three elements. Indices: x, x-1 and x+1
I can assure you that there is a logical error. Since it is already in the pseudocode, I must ask:
Is that a typo by the teacher, or by you?