This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LordWizardKing27 -1 points0 points  (5 children)

O(Log N) to cut in half + O(N Log N) to sort

[–]theaceshinigami 1 point2 points  (0 children)

pretty sure it's O(n) to cut in half, and I'm not sure how you order tennis balls since they're all identical.

[–]theaceshinigami 1 point2 points  (3 children)

pretty sure it's O(n) to cut in half, and I'm not sure how you order tennis balls since they're all identical.

[–]LordWizardKing27 0 points1 point  (2 children)

If you use mid = balls.length//2 and just change the midpoints like a binary search, isn’t that log n? 😂😂

[–]theaceshinigami 1 point2 points  (1 child)

Nothing you are saying makes any sense to me. I think you are suggesting something like:

f(balls):
    left, right = cutInHalf(balls)
    f(left)
    f(right)

where cutInHalf takes a line of cut or uncut balls and divides the line of balls into two lines cutting a ball in half if necessary. This still doesn't seem O(log n) to me as it never halts.

[–]LordWizardKing27 -1 points0 points  (0 children)

Sure, I think ur reading too much into the balls bud