Evaluate the worst case running time of the following algorithm
in Big-O notation in terms of the variable n. Must justify your
answers.
(1) public stitic void main(String[] args) { int sum = 0; int n; for(int i=0; i < 99; i++) { for(int j= 1; j<n; j++){ sum++; } } } (11) public static void main(String[] args) { int n; for(int i=0; i<n* n; i++) for(int i=0; j <i; j++) for(int k=0; k< 10000000000000000; k++) System.out.println(i+j+k): } (111) public void int Q3(int n) { int k = 0; sum = 0; while (k <n) { for(int i=n; i > 0:i--) { for(int i=1; j <i;j++){ sum += 1; } } k=k+ 1; } }
(iv) public void Q4(int n) { int k = 0; for(int i=0; i<n; i++) { k=methodi(i): System.out.print(k): } } public stitic int methodi(int i) { int m=0: for(int i=0; i<j;i++) m++; retrun m; }
Evaluate the worst case running time of the following algorithm in Big-O notation in terms of the variable n. Must justi
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am