Q6. " Bonus Best case analysis in insertion sort "
As shown in Q3. A psoudocode for insertion sort The difference in the best case analysis is that the program will NOT go through the while loop not at all as the array will be already sorted so the condition of ( A[wait -1]>original ) always fail . So, T(n) would be = (c1 + c3 )*(n-1) which is time complexity of O(n). Q7. No.5 in the lab sheet: Psoudocode: Sum(n^2) { For i 1 to n A[i] i * i ; m length(A) ; sum 0; for i 1 to m sum sum + A[i]; return sum; } No.8 in the lab sheet: Psoudocode: i2; while i > = 2 { If is prime devisors are 2 OR 3 OR both return i ; } ** the code is not in the strict sense as its not terminating