For each of the below code snippets, identify the asymptotic runtime (i.e., big-Oh) of the code segment: 0; O na = (a) (
Posted: Sun May 15, 2022 7:52 am
For each of the below code snippets, identify the asymptotic runtime (i.e., big-Oh) of the code segment: 0; O na = (a) (2 points) int a int b O; int m n*n; while(a < n) a=a+1; while(b < m/100) b=b+1; 1 Оп O log n n O nlog n Other: O n3 O na 2n o nn O1 O n2 (b) (2 points) for(i = 0; i < n; i++) for(j = 0; j < i; j++) arr += arr[j]; Ο η O log n On log n O Other: O n3 o na 2n o nn =
(C) (2 points) for(i = 0; i < 1000; i++) { for(j = 0; j <i; j++) { arr[j] [k] = 0; } } 81.88 Ο η O log n On log n O Other: n" (d) (2 points) for(i = 1; i <n; i=i*3) for(j = 0; j <n; j++) printf( "Hello world\n" ); 01 On n? log n On log n O Other: SS 21 n" (e) (2 points) int rec( int n ) { if(n==1) return 0; return 1 + rec(n/3); /* rec call */ } O 1 On n2 O log n On log n O Other: n? 2" oo On4 nh
(C) (2 points) for(i = 0; i < 1000; i++) { for(j = 0; j <i; j++) { arr[j] [k] = 0; } } 81.88 Ο η O log n On log n O Other: n" (d) (2 points) for(i = 1; i <n; i=i*3) for(j = 0; j <n; j++) printf( "Hello world\n" ); 01 On n? log n On log n O Other: SS 21 n" (e) (2 points) int rec( int n ) { if(n==1) return 0; return 1 + rec(n/3); /* rec call */ } O 1 On n2 O log n On log n O Other: n? 2" oo On4 nh