Have a question about a Quiz 1 answer...
In problem 7.2, it asks, "Under the assumption that logBase2 is O(n), what is the order (use big Oh notation) of f(n)?"
The answer says that it is still O(n), but it seems like it should be O(nlogn), as f(n) has a loop which executes as many times as the logBase2(n) value. Therefore, the call to logBase2(n) will be O(n), and the loop is O(log(n)), so shouldn't the entire function be O(nlogn)?
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Okay, I hadn't seen Recitation 5 that goes over the answers. The reason that Problem 7.2 on Quiz 1 isn't O(nlogn) is because the O(logn) section of the code is additive with the O(n) section, and so the O(n) dominates. If the program were written in such a way that the O(logn) section were *inside* the code performing the O(n) function, then the entire piece of code would, indeed, be O(nlogn).