697 views
0 votes
0 votes

Let P be a procedure that for some inputs call itself (i.e. recursive). If P is guaranteed to terminate, which of
the following must be true?
1. P has local variable
2. P has an execution path where it does not call itself
3. P either refers to a global variable or has atleast one parameter

  • 1 only
  • 2 only
  • 1 and 2 only
  • 2 and 3 only

1 Answer

0 votes
0 votes

P has an execution path where it does not call itself

that is true prvoided this path excutes some time in future.


P either refers to a global variable or has atleast one parameter.

it needs to refer to some external variable which will help to activate a path mentioed in step 2.

but the thing garuntes is confusing since. a bad coder like me may go into infite loop with improper implemantion of aqbove condition

Related questions

3 votes
3 votes
3 answers
1
Laxman Ghanchi asked May 19, 2023
1,113 views
#include<stdio.h void print(int n) { printf("Hello "); if(n++ == 0) return ; print(n); n++; } int main() { void print(); print(-4); }How many times printf execute?? And H...
0 votes
0 votes
1 answer
2
Laxman Ghanchi asked May 19, 2023
658 views
#include<stdio.h>void print(int n){ printf("Hello "); if(n++ == 0) return ; print(n); n++;}int main(){ void print(); print(-4);}
1 votes
1 votes
0 answers
4