Why is this time complexity O(n)?
complexity-theory
Solution
The code iterates through `n^2/2` (half a square matrix) locations in the array, so its time complexity is `O(n^2)`
Problem
Why does the below function have a time complexity of O(n)? I can't figure it out for the life of me. ``` void setUpperTriangular ( int intMatrix[0,…,n-1][0,…,n-1]) { for (int i=1; i<n; i++) { for (int j=0; j<i; j++) { intMatrix[i][j] = 0; } } } } ``` I keep getting the final time complexity as O(n^2) because: ``` i: execute n times{//Time complexity=n*(n*1) j: execute n times{ //Time complexity=n*1 intMatrix[i][j] = 0; //Time complexity=1 } } ```