Insertion Algorithm

  coolteentom 14:04 03 Jun 2008


Am just trying to figure out insertion algorithms, and have come across a particular line which I cannot quite decipher:

for count := rp to cp + 1 step -1

In particular, I have not come across the word 'step' before. I understand that if it was just 'count := rp', the value of 'rp' would be assigned to 'count', but could someone explain the other part of the line?

Thanks, Tom

  woodchip 14:19 03 Jun 2008

Do not know nothing much about this, You must be using Excel take a look it may help click here

  VoG II 14:37 03 Jun 2008

That isn't Excel VBA as far as I can see.

What it is doing is counting DOWN in steps of 1 from rp to cp+1.

  coolteentom 15:10 03 Jun 2008

Thanks for the replies -

Have tried your suggeston VoG, but doesn't seem to work :(

At this particular line of code: rp = 2, cp = 1.

I am working this algorithm from a book, and apparently the anwer to this line is "2", so Count is assigned the number 2... but I can't work out why.

Using the step down idea, I would be counting down from rp(=2) to cp+1(=2) which would equal zero?

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

50 best online Adobe XD tutorials

iPad Pro 10.5in (2017) review

Comment connecter un MacBook à une TV ?