Determine the time complexity of the following algorithm:
```
Initialize variable sum to 0
for each element i from 1 to n
for each element j from 1 to i
increment sum by 1
return sum
```
O(n log n)
O(n^2)
O(n)
O(2^n)
Data Structures and Algorithms Exercises are loading ...