Question 1: Growth Analysis 10 points For each of the below code snippets, identify the asymptotic runtime (i.e., big-Oh
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Question 1: Growth Analysis 10 points For each of the below code snippets, identify the asymptotic runtime (i.e., big-Oh
Question 1: Growth Analysis 10 points For each of the below code snippets, identify the asymptotic runtime (i.e., big-Oh) of the code segment: nu (a) (2 points) int a = 0; int b = 0; int m= n*n; while(a <n) a=a+1; while(b < m/100) b=b+1; 0 1 On On? Olog n On log n O Other: On3 2n n" (b) (2 points) for(i = 0; i<n; i++) for(j = 0; j <i; j++) arr += arr[j]; O1 On O na Ologn On log n O Other: On3 02 On4 Onn (c) (2 points) for(i = 0; i < 1000; i++) { for(j = 0; j <i; j++) { arr[j] [k] = 0; } } 01 Оп On? O log n On log n O Other: On? 02" oo nº On" n4 (d) (2 points) for(i = 1; i<n; i=i*3) for(j = 0; j<n; j++) printf("Hello world\n" ); 0 1 On O na log n On log n O Other: On3 21 on" (e) (2 points) int rec( int n) { if( n<=1 ) return 0; return 1 + rec(n/3); /* rec call */ } O1 On On? logn On log n O Other: On? O2n 8 oo n4 On
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!