In this example, I have two separate for loops. Is the running time O(num1 + num2)?
for(int i=0; i< num1 ; i++)
{
print i;
}
for(int i=0 ; i<num2 ; i++)
{
print i;
}
And for this example, there is a nested for loop. Would the running time be O(num1*num2) because for each number in 0 to num1, you have to iterate from 0 to num2?
for(int i=0 ; i<num1 ; i++)
{
for(int j=0 ; j<num2 ; j++)
{
print i;
}
}