upvote
In terms of physical effort taken it’s O(n). Move half, then a quarter, then one eighth, etc.

The number of partitions doesn’t matter either, the most straightforward case is the beeping box always being in the original room, so regardless of strategy you move n-1 boxes to narrow it down, and by symmetry it doesn’t matter which room beeps.

reply
It's O(logn) but you haven't accounted for how heavy each item in the array of n is.
reply
You can just move the lightest half of the boxes each time.
reply
A few additional constraints:

  - the boxes are stacked
  - the heavy boxes are at the bottom of a stack, and you can't stack a heavy box on top of a light one
  - boxes aren't the same size
  - some boxes are open, so must be put on top
  - storage space and height are limited
reply
If you randomly index them and there's enough of them then on average the partitions average out.
reply
This is true, but it probably isn't a box of books that's beeping.

I also feel like ordering the moves by lightest box first is reasonable as a real-world optimization.

reply
Typically, the heavy boxes are at the bottom too; to some extent, the piles will already be sorted by weight.
reply
Lol classic “ignore the constant factor” gotcha when using Big-O.
reply
Or you could use a very heavy blanked to just cover some boxes to supress the sound enough to simulate moving boxes.
reply
You are moving n/2 objects log(n) times, so its O(n.log(n))
reply
Only half of the remaining boxes need to be moved, not half of the total.
reply
Never ignore the constant factor.
reply
That was my proposed solution to finding something just today; it didn’t work, but one of the bags ended up containing an old contract from General Development Company. Apparently a late family member had been buying some land down there through them, but county appraisers showed that the land never changed hands until after GDC’s bankruptcy. Not even their kid had heard about this, so it really makes me wonder what the story was behind that considering they lived in the Midwest (but did have some relatives nearby in Florida).
reply
Yes, but that's also O(log n) physical effort. This one's O(1) sitting on your butt.

(Out of curiosity: I think "physical binary search" is more properly O(n^{1/3} log(n)), or maybe O(n^{1/2} log(n)). Since physical objects have sizes, and moving things (or moving between things) takes time proportional to distance).

reply
Good point about the moving effort required. But if moving an object takes constant time, then it's O(n) overall -- since <incorrect argument deleted>.

EDIT: My earlier analysis was wrong (it assumed you never move the beeping item after the initial halving), but the conclusion was right for a different reason: Each time you move items, you move half as many as you did last time. You initially move n/2 items, and the geometric series n/2 + n/4 + n/8 + ... + 1 sums to n-1. So O(n) moves are done, and this dominates the log n term for the number of steps.

reply
Yeah, that interpretation is more realistic!

O(log n) is if you can split the collection in half in an O(1) step, like, *shoving* the whole pile together as a unit

O(n) if you're moving items one at a time. So, splitting the pile in half once is O(n)

O(n^{3/2}) if the project is way out of control and walking distances start to matter

reply
It’s not sitting on your butt if you have to code an entire system and set up notes throughout the house and monitor them.
reply
You just look in the last box first, duh.
reply
That requires you to stand in the room and listen for which side. So it’s nlogn times a very long time constant
reply
> Move half the boxes to another room.

Alternatively, no.

reply
Alternatively, you can unpack
reply
Came here to say this.
reply
Who's got that kind of time?
reply
I am confident that inventing a new networked sound locating system is far easier than that.
reply
More interesting for sure
reply
deleted
reply
Yes, if you still didn't unpacked it when you don't need it.
reply
You could also solve it by getting rid of the boxes of stuff you clearly don't need (if you needed it, it wouldn't still be in a box). The best way to solve a problem is to make the problem go away.
reply
> if you needed it, it wouldn't still be in a box

I like to keep a lot of things in storage, and sometimes go through my boxes and “rediscover” things I haven’t used in a while.

Sure I have a lot of things I never use also. Some things I could sell, and some things I could give away, and some things I could throw away.

But just because a lot of things are in boxes, doesn’t mean that I might as well get rid of all of it for that reason alone.

reply
Step one: burn down half the house. If the beeping stops, the device was in the first half. If not, burn down the other half of the house.
reply
This has got me thinking, I wonder how many garbage trucks are beeping right now.

And the piles of rubbish at the landfill are probably beeping too.

reply
What a horrifying thought.
reply