Unless I am mistaken k is the current array index and n is the initial array index, so the step "Repeat while k < n" is a noop. I presume it should say "Repeat while k < length"