educative.io

Search workflow for a place in Yelp

What will be the search workflow? We will first find the node that contains the user’s location. If that node has enough desired places, we can return them to the user. If not, we will keep expanding to the neighboring nodes (either through the parent pointers or doubly linked list) until either we find the required number of places or exhaust our search based on the maximum radius.

is below the main idea?

  1. start from root
  2. traverse down and find node with location
  3. if node does not have enough places, check sibling nodes
  4. if sibling nodes don’t have enough places, check their siblings and so on.

Yes. It is the basic idea. But here we can also check either through parent node or doubly lined list where we can move either forward or backward.

  1. traverse down and find node with location
    @Asma_Yasin
    Can you tell me which location are you searching here?
    Is this your location, if yes, it means Are we saving User’s locations in the tree?
    And if yes, Are we sure we really wanna save literally every user’s location on planet?