Pretty crazy that we're closer to 2030, than we are 2005. Where did the time go!
0 Members and 3 Guests are viewing this topic.
Quote from: Camel on October 15, 2007, 01:04:40 pmAn example of O(log(n)) would be a quicksort, because the number of iterations increases linearly as n increases proportionally. That is to say, each time you double the size of the input array, the run-time increases by a constant amount.Quicksort is in the average case, in the worse case (which occurs when the list is already sorted).An example of a algorithm is binary search.
An example of O(log(n)) would be a quicksort, because the number of iterations increases linearly as n increases proportionally. That is to say, each time you double the size of the input array, the run-time increases by a constant amount.
I don't know about the original problem, Camel. I suppose you could do binary search instead of a linear search, if you make sure everything is in ascending order? That's better than the O(n) you have there. I guess that's what you were hinting at, though. It's sort of an ugly problem, because you're going to have to muck something up. You either do a search, which seems silly, or add a bunch of filler elements, which also seems silly. I say you tell Java to fix the way enums work.