Calculate the time complexity of the following program fragments.
(a) ššš (š = 1; š ⤠š; š ā = 2)
{ š„=š„+1 }
(b) ššš (š = 1; š ⤠š; š + +)
ššš (š = 1; š ⤠š; š = š ā 2) {
....
....
}
a)
It is executed, for
The time complexity:
b)
It is executed, n times for
The time complexity: