What is the time complexity of below code? The loop variable ‘i’ is incremented by 1, 2, 3, 4, … until i becomes greater than or equal to n. The value of i is x(x+1)/2 after x iterations. So if loop runs x times, then x(x+1)/2 < n. Therefore time complexity can be written as… Read More »
The post Time Complexity where loop variable is incremented by 1, 2, 3, 4 .. appeared first on GeeksforGeeks.