Spring 2001 CS100M Solutions to Exercise E10 + here are how many people chose each answer; solutions are marked with an arrow $-->$. + see also the $e10maple$ script + see also the $e10plot$ script 1. x = [n]; --> 154: $length(x)$ is O(1) 22: $length(x)$ is O(n) 4: $length(x)$ is none of the above 2. x = 1:n; 21: $length(x)$ is O(1) --> 151: $length(x)$ is O(n) 2: $length(x)$ is O(n^2) 6: $length(x)$ is none of the above 3. x = [2]; for j = (n-5):(n+5), x = [x 2]; end $length(x)$ is O(1) --> 73: $length(x)$ is O(1) 24: $length(x)$ is O(n) 2: $length(x)$ is O(n^.5) 6: $length(x)$ is O(n^2) 75: $length(x)$ is none of the above 4. O(100 n^2 + 5n + 1) = O(n^2 + 5n + 100) 27: $O(100 n^2 + 5n + 1)$ is bigger 2: $O(n^2 + 5n + 100)$ is bigger --> 151: they are the same 5. O(10 n^2) < O(2 n^10) 3: $O(10 n^2)$ is bigger --> 176: $O(2 n^10)$ is bigger 1: they are the same 6. O(10) = O(1) 1: $O(1)$ is bigger 26: $O(10)$ is bigger --> 153: they are the same 7. O(1 + 1/n) = O(2) 17: $O(1 + 1/n)$ is bigger 69: $O(2)$ is bigger --> 94: they are the same 8. O(n+log(n)) = O(n) 2: $O(n)$ is bigger 48: $O(n+log(n))$ is bigger --> 130: they are the same Histogram of number of correct replies 34 number of correct answers: 8 45 number of correct answers: 7 42 number of correct answers: 6 25 number of correct answers: 5 11 number of correct answers: 4 14 number of correct answers: 3 5 number of correct answers: 2 1 number of correct answers: 1