recategorized by
373 views
0 votes
0 votes

What would be the worst case time complexity of an unreachable code?

Let's say there are two parts to the code, where first part is if (0) with complexity O(n) and the else part with O(1).

 

Something like this:

if (0) {

 Time complexity O(n)

}

else

    return

 

Logically, it would be O(1) because we'll never reach the fragment of code inside if(0).

When we calculate worst case time complexity do we consider only the theoretical aspects or we deduce it logically?

Is there any resource to support this? How is time complexity calculated for unreachable code?

 

Thanks

Registered user 48

 

 

recategorized by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
1
gateexplore asked Oct 25, 2023
129 views
It is always true that Recursive code is easier to debug?? If yes then why?? please give full explanation.
0 votes
0 votes
4 answers
3
Aryanzzzz asked Jan 16, 2023
467 views
A recursion program without a terminating condition will provide infinite output. True/False?
0 votes
0 votes
3 answers
4
Nisha Bharti asked Sep 26, 2022
727 views
What is the time & space complexity of this algorithm?Main(){ for(i=n; i>10; i=i^1/4) { for(j=201; j<n^3; j=j+400) ...