SPECIFICATION V1.0

BITSORT_ALGO

BINARY TRIE-BASED SORTING SYSTEM

01. Abstract

BitSort is a non-comparison based sorting algorithm. It utilizes a binary trie structure to organize elements bit by bit, resulting in a predictable time complexity relative to the bit-depth of the input data type.

COMPLEXITY

O(N * K)

N: Total elements
K: Bit size (e.g., 32 for int)

SPACE

DYNAMIC

Directly proportional to unique element distribution.

02. Mechanism

The algorithm decomposes each integer into its constituent bits, traversing from MSB to LSB. Each bit determines the path taken through a binary tree of 'Blocks'.

0_____________________|_____________________1 / \ 0_________/_________1 0_________\_________1 / \ / \ 0___/___1 0___\___1 0___/___1 0___\___1 / \ / \ / \ / \ cnt cnt cnt cnt cnt cnt cnt cnt

03. Data Structure

The core structure uses a memory-efficient union to represent internal nodes and leaves.

typedef union Block {
    int cnt[2];      // Leaf: bit counters
    Block* node[2];  // Internal: child pointers
} Block;

04. Performance Analysis

N (Count) Distribution Memory Usage Duration
1,000,000 Same Value 512 Bytes ~0.02s
1,000,000 Sequential ~16 MB ~0.2s
1,000,000 Uniform Random ~179 MB ~1.4s

05. Implementation Notes