InterviewSolution
Saved Bookmarks
| 1. |
(i) What is the worst-case complexity of the following code segment:for(int x = 1; x<=a; x++) { statements; } for(int y = 1; y <= b; y++) { for (int z = 1; z <= c; z++) { statements; } } (ii) How would the complexity change if all the three loops went to N instead of a, b and c? |
|
Answer» (i) O(a + bc) (ii) O(n^2) |
|