Adds ByteByteGo guides and links (#106)

This PR adds all the guides from [Visual
Guides](https://bytebytego.com/guides/) section on bytebytego to the
repository with proper links.

- [x] Markdown files for guides and categories are placed inside
`data/guides` and `data/categories`
- [x] Guide links in readme are auto-generated using
`scripts/readme.ts`. Everytime you run the script `npm run
update-readme`, it reads the categories and guides from the above
mentioned folders, generate production links for guides and categories
and populate the table of content in the readme. This ensures that any
future guides and categories will automatically get added to the readme.
- [x] Sorting inside the readme matches the actual category and guides
sorting on production
This commit is contained in:
Kamran Ahmed
2025-04-01 06:16:44 +01:00
committed by GitHub
parent 44f1251199
commit ee4b7305a2
493 changed files with 15791 additions and 1728 deletions

38
data/guides/quadtree.md Normal file
View File

@@ -0,0 +1,38 @@
---
title: "Quadtree"
description: "Explore the quadtree data structure for spatial data partitioning."
image: "https://assets.bytebytego.com/diagrams/0311-quadtree.jpg"
createdAt: "2024-03-03"
draft: false
categories:
- how-it-works
tags:
- "Data Structures"
- "Algorithms"
---
![](https://assets.bytebytego.com/diagrams/0311-quadtree.jpg)
Let's explore another data structure to find nearby restaurants on Yelp or Google Maps.
A quadtree is a data structure that is commonly used to partition a two-dimensional space by recursively subdividing it into four quadrants (grids) until the contents of the grids meet certain criteria.
A quadtree is an **in-memory data structure** and it is not a database solution. It runs on each LBS (Location-Based Service, see last weeks post) server, and the data structure is built at server start-up time.
The second diagram explains the quadtree building process in more detail. The root node represents the whole world map. The root node is recursively broken down into 4 quadrants until no nodes are left with more than 100 businesses.
## How to get nearby businesses with quadtree?
* Build the quadtree in memory.
* After the quadtree is built, start searching from the root and traverse the tree, until we find the leaf node where the search origin is.
* If that leaf node has 100 businesses, return the node. Otherwise, add businesses from its neighbors until enough businesses are returned.
## Update LBS server and rebuild quadtree
* It may take a few minutes to build a quadtree in memory with 200 million businesses at the server start-up time.
* While the quadtree is being built, the server cannot serve traffic.
* Therefore, we should roll out a new release of the server incrementally to a small subset of servers at a time. This avoids taking a large swathe of the server cluster offline and causes service brownout.