# How Quadtree Data Structure Enables Exploring Millions of Places Instantly on Booking.com

[Booking.com](http://Booking.com)'s Lightning-Fast Location Search.  
  
The most powerful feature on [Booking.com](http://Booking.com) is the map.

![QuadTree, Booking.com](https://media.licdn.com/dms/image/D5622AQE9H7a1S_srew/feedshare-shrink_800/0/1689010890623?e=1691625600&v=beta&t=5RfxOLzd_p781ED19EqWaaXboVegipEYoMyi7CL9D8E align="left")

  
  
There are tens of millions of listed properties on their marketplace, and users can search the map for the location and places nearby.  
  
Thie experience on searching on the map is good only when it loads fast - and it sure does on [Booking.com](http://Booking.com).  
  
How does the backend search millions of different points across the world so quickly?  
  
𝗧𝗵𝗲 𝘂𝗻𝗱𝗲𝗿𝗹𝘆𝗶𝗻𝗴 𝗱𝗮𝘁𝗮 𝘀𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲 𝘁𝗵𝗮𝘁 𝗽𝗼𝘄𝗲𝗿𝘀 𝘁𝗵𝗶𝘀 𝗶𝘀 𝗮 𝙌𝙪𝙖𝙙𝙩𝙧𝙚𝙚.  
  
A quadtree is a data structure used to represent and organize spatial data in a hierarchical manner. It is particularly useful for efficiently partitioning and querying information in two-dimensional space.  
  
Here's how it works:  
  
Start with the big square, which represents the entire space you want to divide and store information about.  
  
Divide the square into four equal-sized smaller squares. These smaller squares are called "quadrants." Each quadrant represents a smaller part of the overall space.  
  
If a quadrant is empty, you don't need to divide it further. You can mark it as empty and move on.  
  
If a quadrant contains information, you can choose to divide it further into four smaller quadrants. You repeat the process for each of these smaller quadrants.  
  
You continue dividing the squares until each quadrant either becomes empty or contains a single point of information. This forms the leaves of the quadtree.  
  
Quadtrees find applications in various fields such as computer graphics, geographic information systems (GIS), collision detection, image processing, and more.  
  
It is also an important system design topic for engineers to have an understanding of.  
  
P.S - Repost this if you found it useful ♻️  
  
P.P.S. If you want to learn more about software architecture and software engineering consider subscribing to my FREE newsletter.  
  
Join 100+ "Adaptive Engineers"👇  
  
[https://lnkd.in/giRgg5yu](https://lnkd.in/giRgg5yu)
