# Algorithms Detailed in the xingshaocheng/architect-awesome Repository: A Complete Backend Catalog

> Explore over 15 algorithm categories like sorting, graph theory, and distributed consensus in the xingshaocheng/architect-awesome repository. Your complete backend algorithm catalog awaits.

- Repository: [xingshaocheng/architect-awesome](https://github.com/xingshaocheng/architect-awesome)
- Tags: architecture
- Published: 2026-03-05

---

**The xingshaocheng/architect-awesome repository catalogs over 15 algorithm categories—including sorting, graph theory, string matching, and distributed consensus protocols—in its README.md "常用算法" section.**

The xingshaocheng/architect-awesome repository serves as a curated knowledge map for back-end architects, organizing essential computer science concepts into a navigable Markdown structure. Its comprehensive README.md dedicates a specific "常用算法" (Common Algorithms) section to documenting foundational and distributed systems algorithms critical for architectural decision-making. Understanding the algorithms detailed in the xingshaocheng/architect-awesome repository provides engineers with a centralized reference for both interview preparation and production system design.

## Core Algorithm Categories in README.md

The central documentation resides in [`README.md`](https://github.com/xingshaocheng/architect-awesome/blob/main/README.md) under the anchor `#常用算法`, which functions as the primary index for all algorithmic content. Each subcategory uses stable markdown headers that serve as permanent deeplinks to specific algorithm families.

### Sorting and Searching Algorithms

The `#排序查找算法` section enumerates ten fundamental data structure algorithms. **Comparison-based sorts** include **Quick Sort**, **Merge Sort**, **Heap Sort**, **Shell Sort**, **Bubble Sort**, **Selection Sort**, and **Insertion Sort**. **Non-comparison sorts** cover **Counting Sort**, **Bucket Sort**, and **Radix Sort**. The section also documents **Binary Search** for O(log n) retrieval in ordered collections.

### String Matching and Optimization Strategies

Dedicated headers cover pattern recognition and strategic optimization techniques:
- **KMP Algorithm** (`#kmp-算法`): Knuth-Morris-Pratt linear-time string pattern matching
- **Greedy Algorithm** (`#贪心算法`): Local optimization heuristics for combinatorial problems
- **Backtracking** (`#回溯算法`): Exhaustive search with state restoration for constraint satisfaction
- **Pruning** (`#剪枝算法`): Search space reduction via early termination conditions

### Graph Theory Algorithms

Two critical anchors address network optimization problems:
- **Minimum Spanning Tree** (`#最小生成树算法`): Kruskal and Prim algorithms for connecting weighted graphs with minimal total edge cost
- **Shortest Path** (`#最短路径算法`): Dijkstra's algorithm for single-source shortest path computation in graphs with non-negative edge weights

## Distributed Systems and Specialized Algorithms

Beyond classical computer science, the repository catalogs algorithms essential for modern distributed architectures and high-scale system design.

### Consensus, Hashing, and Cryptography

- **Distributed Consistency Algorithms** (`#分布式一致性算法`): Documentation covers **Paxos**, **Raft**, and **Gossip** protocols for achieving consensus across distributed nodes
- **Consistent Hashing** (`#一致性hash算法`): Ring-based distribution strategies for load balancing and horizontal scaling
- **Hash Functions** (`#哈希算法`): References to common hash functions including MD5, SHA-1, and SHA-2

### System Design Operational Algorithms

The README integrates algorithms for operational concerns under system architecture sections:
- **Rate Limiting**: **Sliding Window**, **Leaky Bucket**, and **Token Bucket** algorithms (referenced under the "限流" section)
- **Cache Eviction**: **FIFO**, **LRU**, and **LFU** replacement policies for cache management strategies
- **Unique ID Generation**: **Snowflake-style** distributed ID generation algorithms for primary key generation in sharded databases

## Reference Implementation Patterns

While [`README.md`](https://github.com/xingshaocheng/architect-awesome/blob/main/README.md) functions strictly as a knowledge base rather than a code library, the documented algorithms follow standard implementation patterns. The following Java snippets illustrate the core mechanics of the algorithms cataloged in the repository.

### Quick Sort Partition Strategy

```java
public static void quickSort(int[] a, int lo, int hi) {
    if (lo < hi) {
        int p = partition(a, lo, hi);
        quickSort(a, lo, p - 1);
        quickSort(a, p + 1, hi);
    }
}

private static int partition(int[] a, int lo, int hi) {
    int pivot = a[hi];
    int i = lo;
    for (int j = lo; j < hi; j++) {
        if (a[j] <= pivot) swap(a, i++, j);
    }
    swap(a, i, hi);
    return i;
}

private static void swap(int[] a, int i, int j) { 
    int tmp = a[i]; a[i] = a[j]; a[j] = tmp; 
}

```

### Binary Search Implementation

```java
public static int binarySearch(int[] a, int target) {
    int lo = 0, hi = a.length - 1;
    while (lo <= hi) {
        int mid = (lo + hi) >>> 1;
        if (a[mid] == target) return mid;
        else if (a[mid] < target) lo = mid + 1;
        else hi = mid - 1;
    }
    return -1;
}

```

### KMP Pattern Matching

```java
public static int kmpSearch(String txt, String pat) {
    int[] lps = computeLPS(pat);
    int i = 0, j = 0;
    while (i < txt.length()) {
        if (pat.charAt(j) == txt.charAt(i)) { 
            i++; 
            j++; 
        }
        if (j == pat.length()) return i - j;
        else if (i < txt.length() && pat.charAt(j) != txt.charAt(i)) {
            if (j != 0) j = lps[j - 1];
            else i++;
        }
    }
    return -1;
}

private static int[] computeLPS(String pat) {
    int[] lps = new int[pat.length()];
    int len = 0, i = 1;
    while (i < pat.length()) {
        if (pat.charAt(i) == pat.charAt(len)) { 
            len++; 
            lps[i++] = len; 
        }
        else if (len != 0) len = lps[len - 1];
        else lps[i++] = 0;
    }
    return lps;
}

```

### Dijkstra Shortest Path

```java
public static int[] dijkstra(List<int[]>[] graph, int src) {
    int n = graph.length;
    int[] dist = new int[n];
    Arrays.fill(dist, Integer.MAX_VALUE);
    dist[src] = 0;
    PriorityQueue<int[]> pq = new PriorityQueue<>(Comparator.comparingInt(a -> a[1]));
    pq.offer(new int[]{src, 0});
    
    while (!pq.isEmpty()) {
        int[] cur = pq.poll();
        int u = cur[0];
        if (cur[1] != dist[u]) continue;
        
        for (int[] edge : graph[u]) {
            int v = edge[0], w = edge[1];
            if (dist[u] + w < dist[v]) {
                dist[v] = dist[u] + w;
                pq.offer(new int[]{v, dist[v]});
            }
        }
    }
    return dist;
}

```

### Consistent Hash Ring

```java
public class ConsistentHash<T> {
    private final SortedMap<Long, T> ring = new TreeMap<>();
    private final int replicas;
    
    public ConsistentHash(int replicas, Collection<T> nodes) {
        this.replicas = replicas;
        for (T node : nodes) add(node);
    }
    
    public void add(T node) {
        for (int i = 0; i < replicas; i++) {
            long hash = hash(node.toString() + i);
            ring.put(hash, node);
        }
    }
    
    public T get(String key) {
        if (ring.isEmpty()) return null;
        long hash = hash(key);
        SortedMap<Long, T> tail = ring.tailMap(hash);
        return tail.isEmpty() ? ring.get(ring.firstKey()) : tail.get(tail.firstKey());
    }
    
    private long hash(String s) { 
        try {
            return java.security.MessageDigest.getInstance("MD5")
                .digest(s.getBytes())[0];
        } catch (Exception e) { return 0; }
    }
}

```

## Summary

- The **xingshaocheng/architect-awesome** repository documents 15+ algorithm categories in [`README.md`](https://github.com/xingshaocheng/architect-awesome/blob/main/README.md) under the "常用算法" section and specific sub-headers like `#排序查找算法` and `#分布式一致性算法`.
- **Classical algorithms** include ten sorting varieties (Quick, Merge, Heap, Shell, Bubble, Selection, Insertion, Counting, Bucket, Radix), Binary Search, KMP string matching, and graph algorithms (Dijkstra, Kruskal, Prim).
- **Distributed systems** coverage spans consensus protocols (Paxos, Raft, Gossip), consistent hashing, cryptographic hashes (MD5, SHA-1/2), and operational algorithms for rate limiting, caching, and unique ID generation.
- Each algorithm entry in the source provides descriptive context and external reference links; the repository serves as a curated index rather than an implementation library.

## Frequently Asked Questions

### Does the repository contain actual algorithm implementations?

No, the xingshaocheng/architect-awesome repository functions strictly as a curated knowledge base. The [`README.md`](https://github.com/xingshaocheng/architect-awesome/blob/main/README.md) file provides descriptive catalogs, categorization, and external reference links for each algorithm, but does not ship executable source code or function implementations for the documented methods.

### Which distributed consistency algorithms are detailed in the README?

According to the source code in [`README.md`](https://github.com/xingshaocheng/architect-awesome/blob/main/README.md), the `#分布式一致性算法` section documents **Paxos**, **Raft**, and **Gossip** protocols. These entries provide architectural explanations and external references suitable for designing fault-tolerant distributed systems.

### How are the sorting algorithms organized in the documentation?

The sorting algorithms reside under the `#排序查找算法` anchor in [`README.md`](https://github.com/xingshaocheng/architect-awesome/blob/main/README.md). This section groups **Selection Sort**, **Bubble Sort**, **Insertion Sort**, **Quick Sort**, **Merge Sort**, **Shell Sort**, **Heap Sort**, **Counting Sort**, **Bucket Sort**, and **Radix Sort** together with **Binary Search** in a single categorical header dedicated to sorting and searching.

### Are consistent hashing and rate-limiting algorithms included?

Yes, the repository documents **Consistent Hashing** explicitly under the `#一致性hash算法` header. Rate-limiting strategies including **Sliding Window**, **Leaky Bucket**, and **Token Bucket** algorithms are implicitly covered within the "限流" (flow control) system design section of the README.