need help with big o notion. wht i understant you can tell how fast algorithm is running by using big O.
so my question is can any one tell me if i have the anwser right or wrong. if right or wrong can you plz explain as much as you can.
1) this algorithm is running O(n) or n?
Code :for(int i = 0; i < n; i++) { ... }
2) O(10)?
Code :for(int i = 0; i < 10; i++){ ... }
3) o(n)??
Code :int n = array[i].length; for(int i = 0; i < n; i++) if(array[i] == 3) { ... }
4)
Code :for(int i = 10; i > 0; i--) { ... }
5) O(n*m)? n = 1st array size | m = 2nd array size
Code :for(int i = 0; i < n; i++) { for(int x = 0; x < m; x++) { } }
6)O(n*m)?? n=array.length | m=array[y].length
are there any more usefull case?Code :for(int y = 0; y < array.length; y++) { for(int x = 0; x < array[y].length; x++) { .... } }
