Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

Im currently studying the running times of algorithms Big Oh notation. heres the question and my attempts. Algorithms: a) int sum = 0; for(int i = 1; i < N; i < N; i *= 2) for(int i = 0; i < n; i++) sum++; b) int sum = 0 for(int i = 1; i < N; i *=2) for(int j = 0; j < N; j++) sum++; my answers: a) (N-1) + (N-2) + (N-4) + (N-8) + ... + 1 then f(N) <= 4N-14 which is f(N) = O(N)?? b)N*(N-1) + N(N-2)+ N(N-4) + N(N-8) + ... + 1 then, N[(N-1) + (N-2) + (N-4) + (N-8) + ... + 1] then f(N) = O(N^2)?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!