5 ms·
BFS is common sense. It’s what you use when you’ve lost your car keys for example. Quickly check each room in the house, then if no luck go one layer deeper in
by quickthrower2 8y ago
BFS is common sense. It’s what you use when you’ve lost your car keys for example.
Quickly check each room in the house, then if no luck go one layer deeper in each room.
- deleted 8y ago[deleted]
- dekhn 8y agouh, I thoroughly search each room, starting at the left corner and recursively iterating via a hilbert curve. doesn't everybody?
- ghaff 8y agoTwo different approaches. Each have their adherents. But when someone can’t find their phone or keys that that just had, they probably don’t start by ripping one room apart top to bottom.
- Rapzid 8y agoI would certainly probe deeper if given that as evidence for a strong grasp on the utility of BFS.
- quickthrower2 8y agoSo you’d do a DFS on a BFS
- j1elo 8y agoI'd use an indexed search and remote activate the beeper in the key chain
- perl4ever 8y agoThis is actually not how I search. After the first search, if I am getting frustrated, I do what I was told when I was a child: "start picking up stuff until you find it". So I guess that's kind of a depth first search after going over the top layer.
- vishnugupta 8y agoThat's definitely now how I do it. I go deeper into each room, the depth (as well as the order) being decided by (roughly) how much time I spend in each room every day. E.g., Go waay deeper in living room, less so in bedroom, lesser still in bath room and so on :-). This I'd imagine is "more" common sense than than an un-informed BFS?
- mav3rick 8y agoIf you just go depth, it is well depth first :)
- vishnugupta 8y agoI actually thought this through a bit :-) Neither is it a DFS, unlike in DFS I'm expanding nodes at different depths. E.g., I'm shallow expanding bathroom/kitchen compared to living room. Only when I've exhausted living do I return to kitchen again to do a deeper search. I wonder if this kind of search has any other use. Debugging seems like a similar activity. Go deeper into logs, if nothing turns up then examine metrics, read code, return to logs again etc.,? Sorry, past midnight here after a busy day at work :-P
- Jach 8y agoHeuristically guided search. :) For some nodes you go wide, for some deep, sometimes you retreat back up a few levels instead of exhausting a subtree (but you might come back to that subtree later), all depending on what the heuristic says is more likely to get you to your goal the quickest. A* is a well-known base algorithm for this, widely used in game programming to efficiently find the shortest path from A to B in the presence of obstacles etc.
- heptathorp 8y agoA DFS would be you check your living room, you check under the cushions of the sofa, you tear open the cushions and comb through the insides... all before glancing at your bedroom when you didn't quickly see the keys in the living room.
- sys_64738 8y agoI don't think I've ever lost my car keys so does that make me a NULL pointer!
- quickthrower2 8y agoIn that case you get O(1) regardless of algo choice.