0 votes 0 votes // Here c is a constant for (int i = 1; i <= c; i++) { // some O(1) expressions } here complexity is o(1) but how can any one please tell me ? Algorithms time-complexity + – saurabh12345 asked Jul 23, 2018 retagged Jun 18, 2022 by makhdoom ghaya saurabh12345 245 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Since c is a constant that means given loop iterate constant time let us consider c=5,then 5 times c=10,then 10 times that means loop runs only constant time and constant time is nothing but O(1). imnitish answered Jul 23, 2018 imnitish comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Hope this will help. Given, C is a contstant. You can take any value of c, either small or big. The loop will for that fixed c time, which makes the time complexity as O(1). If instead of Constant there is any other variable (let's say n) which is not constant then the complexity will change to O(n). Sumit Singh Chauhan answered Jul 23, 2018 Sumit Singh Chauhan comment Share Follow See all 0 reply Please log in or register to add a comment.