Question
All questions in this sheet must be answered with the demonstrated detailed steps to demonstrate working out the solutions. QUESTION ONE [25 marks ] Determine
All questions in this sheet must be answered with the demonstrated detailed steps to demonstrate working out the solutions.
QUESTION ONE [25 marks ]
Determine the Big O Notation Algorithmic Complexity for each of the following problems below , showing clearly step by step how you came by your answers.
a. (2n+2)3 / 4n 3 [ 2 marks ]
b. 1/2n * [ (n+4)3 ] [ 2 marks ]
c. n(n+8)(2n +1)2] [ 2 marks ]
d. (n+4) / 2n7 [ 2 marks ]
e. [(2n+4)(n +3)2]/n [ 2 marks ]
f. (5n+1)3 / n7 [2 marks ]
g. n4 +2n6 + n [2 marks ]
h. for (i=2; i<4; i+=2){ [2 marks ]
for (j=0; j sum= sum + 3; } } i. for (i=0; i for (j=0; j A[i] = random(n); sort(A, n); } } j. sum = 0; [2 marks ] for (i = 0; i < n; i++) { if (is_even(i)) { for (j = 0; j < n; j++) sum++; } else sum = sum + n; } k. List *SearchList(List *a, int key) { // The list has n elements if (a == NULL) return NULL; // not found else if (a->data == key) return a; else return SearchList(a->next, key); [ 2 marks ] L. int somefunc(int n) { if (n <= 1) return 1; else return somefunc(n-1) + somefunc(n-1); [2 marks ] j. Order the functions from part (a) to part(l) from best case to worse case complexity [ 1 marks ]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started