-1
$\begingroup$

well-known that a loop-programm in Theoretical computer science always terminates, but why do that java example not?

for( ; ; ){ } 
$\endgroup$
2
  • 1
    $\begingroup$ In theoretical computer science a loop program will not terminate. $\endgroup$
    – nir shahar
    Oct 2 at 8:42
  • $\begingroup$ Nir, a loop program is a program in a specific language where the maximum number of iterations of each loop is calculated before loop starts, and that doesn’t allow recursion. With these limitations, it always ends. $\endgroup$
    – gnasher729
    Oct 2 at 15:10
2
$\begingroup$

Bounded loops terminate, unbounded (as in your example) don't necessarily terminate.

$\endgroup$
0
$\begingroup$

In a “loop program”, the maximum number of iterations for each loop needs to be calculated before the loop starts iterating. In your example that is not the case, so you can’t draw any conclusions that you can draw for “loop programs”.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.