I do understand Input until step 4 (If my understanding is correct) but step 5 is a bit confusing because I don't know what should I put in |S1| + |S2| ≥ k -- I'm not even sure if it's an absolute value or what. I don't get the iterations too. Uhmm
So after step 4:
Therefore
|S1| > k
then it contains the k-th element of S|S1| + |S2| > k
then S2 contains the k-th element of S which is therefore p (k-|S1|-|S2|)
element of S3. Therefore you restart (ie iterate) the same algorithm with S = S3
and k=k-|S1|-|S2|
. Hope this help.