Find the Exact Growth Function and Asymptotic Order:
for (int i – 1; i < n; i += 3) { // 1 + (((n-1)/3) + 1) + ((n-1)/3)
ans = i/8 + j*5; // 4 * ((n-1)/3)
}
My question is: Is the ((n-1)/3) floor or ceiling? My teacher said it was floor, but I think it’s ceiling.
Expert Answer
it should be ceiling
take this example take n=12
so now i can take values of 1,4,7,10 as it will be incremented by 3 by this floor(12-1/3) = 3 which is saying that it can take only 3 values but it took 4 values so it should be ceiling.