How would you determine a loop is a infinite loop and will break out of it.
Does anyone has the algorithm or can assist me on this one.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no general case algorithm that can determine if a program is in an infinite loop or not for every turing complete language, this is basically the Halting Problem.
The idea of proving it is simple:
A.Bthat invokesAon itself [onB].Aanswers “the program will halt” – do an infinite loopAanswersBdoesn’t halt] – halt immidiatelyNow, assume you invoke
AonB– the answer will be definetly wrong, thusAdoesn’t exist.Note: the above is NOT a formal proof, just a sketch of it.