Lesson hub

Can't find the answer? Try online tutoring

How it Works

We have the UK’s best selection of online tutors, when and for how long you need them.

Getting 1-on-1 support is cheaper than you might think.

Participating users

Welcome to our free-to-use Q&A hub, where students post questions and get help from other students and tutors.

Follow the trail of responses and if you have anything to add please sign up or sign in.

You can ask your own question or look at similar Applied Mathematics questions.

Hi Jain,

I cannot see your entire post, however, the loop invariant is a condition that holds true after every iteration through your loop. For instance, if you have a function that finds the sum of elements in a list:

sum = 0

for i in list
       sum = sum + list[i]

Your loop invariant will be sum = list[0]+...+list[i] and i < length(list) as this will true for every iteration of your code.

Does this make sense?

Footer Graphic