What is the time complexity for infinite loops
Question 1 what is T(n) for this case
While(1)
{
a=a+b;
}
Question 2 for this case
if(1)
{
for i to n
a=a+b
}
else
{
for i to n
for j to n
a=a+b
}
Edit 2: Compiled the code never goes to the else part
#include<stdio.h>
int main()
{
int a=2,b=6;
if(1)
{
a=a+b;
}
else
{
b=a;
printf("Test");
}
printf("%d %d",a,b);
return 0;
}
output I get is 8 6 which means the else case is never executed hence in worst case do we have to consider the else part.