원클릭으로
algorithms
Use when researching algorithms, data structures, optimization, performance, or need modern alternatives to classic algorithms
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when researching algorithms, data structures, optimization, performance, or need modern alternatives to classic algorithms
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when researching state-of-the-art algorithms for a problem, finding academic papers, comparing algorithm approaches, needing paper citations, or user invokes /algorithm-research
Use when creating benchmarks, measuring performance, comparing implementations, or user invokes /benchmark. Provides step-by-step workflow for benchmark creation, data generation, and results interpretation.
Use when analyzing code cognitive load, onboarding difficulty, or user invokes /cognitive-audit for complexity analysis and refactoring recommendations
Use when analyzing cognitive load, code complexity, onboarding difficulty, readability concerns, maintainability issues, or applying Ousterhout principles for deep modules, reducing complexity, and strategic programming approaches
Use when implementing concurrent operations, choosing between concurrency models, designing async workflows, or working with parallel data processing
Use when validating input data, implementing parse-don't-validate patterns, designing validation pipelines, or handling external data safely
| name | algorithms |
| description | Use when researching algorithms, data structures, optimization, performance, or need modern alternatives to classic algorithms |
This skill provides comprehensive guidance on modern algorithms and data structures from recent computer science research, with focus on practical implementations. Modern algorithms often provide significant performance improvements over classic approaches through better cache utilization, parallelization, and probabilistic techniques.
Use this skill when:
Modern hash functions significantly outperform classic algorithms like MD5 and SHA1 for non-cryptographic use cases.
Overview: Extremely fast non-cryptographic hash function optimized for modern CPUs with SIMD instructions.
Performance:
Use Cases:
Paper: "xxHash: Fast Hash Algorithm" (Collet, 2020)
Overview: Cryptographic hash function that's significantly faster than SHA-2/SHA-3 while maintaining security.
Performance:
Use Cases:
Paper: "BLAKE3: One Function, Fast Everywhere" (O'Connor et al., 2020)
For language-specific implementations:
references/elixir.md - exhash, b3 librariesreferences/rust.md - xxhash-rust, blake3 cratesProbabilistic structures trade perfect accuracy for dramatic space savings and speed improvements. Essential for large-scale systems.
Overview: Estimates cardinality (unique count) with configurable accuracy using minimal memory.
Space Complexity:
Accuracy:
Use Cases:
Performance Comparison:
Counting 10M unique items:
- Exact (HashSet): 800 MB memory, 100% accurate
- HyperLogLog: 12 KB memory, 98% accurate
Paper: "HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm" (Flajolet et al., 2007)
Implementation pattern:
class UniqueVisitorTracker:
# 16-bit precision = ~0.8% error, 64 KB memory
hll = HyperLogLog.new(precision=16)
def track_visitor(user_id):
hll.add(str(user_id))
def get_count():
return hll.count()
Overview: Space-efficient probabilistic data structure for set membership testing. Improves on Bloom filters by supporting deletion.
Advantages over Bloom Filters:
Space Complexity: ~1.5 bytes per item for 3% false positive rate
Use Cases:
Performance Comparison:
Storing 1M items with 2% false positive rate:
- Exact (HashSet): 80 MB, 100% accurate, supports deletion
- Bloom Filter: 1.8 MB, 2% FP rate, no deletion
- Cuckoo Filter: 1.5 MB, 2% FP rate, supports deletion
Paper: "Cuckoo Filter: Practically Better Than Bloom" (Fan et al., 2014)
Implementation pattern:
class CacheFilter:
filter = CuckooFilter.new(capacity=10_000_000, fpr=0.01)
def mark_cached(key):
filter.add(key)
def is_cached(key):
return filter.contains(key)
def invalidate(key):
filter.delete(key) # Unlike Bloom filters!
Overview: Probabilistic data structure for frequency estimation in streams. Answers "how many times has X appeared?" with bounded error.
Space Complexity: Configurable based on error bounds (typically few KB for millions of items)
Accuracy: Overestimates by at most ε×N with probability 1-δ
Use Cases:
Performance Comparison:
Tracking 100M events with 1% error:
- Exact (HashMap): 1.6 GB memory
- Count-Min Sketch: 40 KB memory
Paper: "An Improved Data Stream Summary: The Count-Min Sketch and its Applications" (Cormode & Muthukrishnan, 2005)
Implementation pattern:
class FrequencyTracker:
# 0.1% error, 99% confidence
cms = CountMinSketch.new(epsilon=0.001, delta=0.01)
def track_event(event_type):
cms.add(event_type)
def get_frequency(event_type):
return cms.count(event_type)
For language-specific implementations:
references/elixir.md - hyperloglog, cuckoo_filter librariesreferences/rust.md - probabilistic cratesModern CPUs have multiple cache levels (L1, L2, L3). Cache-oblivious algorithms automatically adapt to cache hierarchy without tuning.
Overview: Algorithms designed to work efficiently across all cache levels without knowing cache parameters.
Key Principle: Divide-and-conquer with base cases small enough to fit in cache.
Example - Matrix Multiplication:
class CacheObliviousMatrix:
# Base case threshold (tune to L1 cache size)
BASE_CASE = 64
def multiply(a, b):
n = len(a)
if n <= BASE_CASE:
return naive_multiply(a, b)
else:
# Divide matrices into quadrants
(a11, a12, a21, a22) = subdivide(a)
(b11, b12, b21, b22) = subdivide(b)
# Recursively multiply submatrices
c11 = add(multiply(a11, b11), multiply(a12, b21))
c12 = add(multiply(a11, b12), multiply(a12, b22))
c21 = add(multiply(a21, b11), multiply(a22, b21))
c22 = add(multiply(a21, b12), multiply(a22, b22))
return combine(c11, c12, c21, c22)
Performance Impact:
Paper: "Cache-Oblivious Algorithms" (Frigo et al., 1999)
Overview: Self-balancing tree optimized for systems with cache/disk hierarchy. Used in databases.
Key Properties:
Use Cases:
Performance Comparison:
1M items, random access:
- HashMap: O(1) average, poor cache locality
- Binary tree: O(log n), poor cache locality
- B+ tree: O(log n), excellent cache locality, 3-5× faster
Overview: Variant of quicksort with better cache behavior through block-wise partitioning.
Key Innovation: Process elements in blocks that fit in CPU cache, reducing cache misses.
Performance:
Paper: "BlockQuicksort: How Branch Mispredictions don't affect Quicksort" (Edelkamp & Weiß, 2016)
Implementation pattern:
class BlockQuicksort:
BLOCK_SIZE = 128 # Typical L1 cache can hold ~512 elements
def sort(list):
if len(list) <= BLOCK_SIZE:
return standard_sort(list) # Use native sort for small lists
pivot = select_pivot(list)
# Partition in blocks for cache efficiency
(left, equal, right) = partition_blockwise(list, pivot)
# Recursively sort partitions (can parallelize)
sorted_left = sort(left)
sorted_right = sort(right)
return sorted_left + equal + sorted_right
Overview: Hybrid sorting algorithm that detects patterns (sorted, reverse-sorted, equal elements) and adapts strategy.
Key Features:
Performance:
Paper: "Pattern-defeating Quicksort" (Orson Peters, 2021)
| Use Case | Modern Algorithm | Classic Alternative | When to Switch |
|---|---|---|---|
| Hashing (non-crypto) | xxHash3 | MD5, SHA1 | Always - 60× faster |
| Hashing (crypto) | BLAKE3 | SHA-256 | When performance critical |
| Unique Counting | HyperLogLog | HashSet/exact count | >100K unique items |
| Membership Testing | Cuckoo Filter | Bloom Filter | Need deletion support |
| Frequency Estimation | Count-Min Sketch | HashMap counter | Millions of items |
| Sorting Large Data | BlockQuicksort | Standard quicksort | >10K items on modern CPU |
| Sorting with Patterns | pdqsort | Quicksort | Data has patterns |
| Matrix Multiplication | Cache-oblivious | Naive O(n³) | Large matrices (>1000×1000) |
| Database Indexes | B+ Tree | Binary tree | Persistent storage |
# Non-cryptographic (fast checksums, hash tables)
hash64(data) # 64-bit hash
hash128(data) # 128-bit hash
# Cryptographic (integrity, signatures)
blake3_hash(sensitive_data)
# Message authentication
hmac_sha256(key, message)
# Cardinality estimation (unique counts)
hll = HyperLogLog.new(precision=14)
hll.add(item)
count = hll.count()
# Membership testing (with deletion)
filter = CuckooFilter.new(capacity=1_000_000)
filter.add(item)
filter.contains(item)
filter.delete(item)
# Frequency estimation
cms = CountMinSketch.new(epsilon=0.001, delta=0.01)
cms.add(event)
count = cms.count(event)
Problem: MD5 and SHA1 are slow for non-cryptographic hashing.
# SLOW - cryptographic hash for non-security use
md5_hash(data) # ~0.5 GB/s
# FAST - modern non-crypto hash
xxhash3_64(data) # ~31 GB/s
When to fix: Hashing for hash tables, checksums, deduplication (not security).
Problem: Using exact counts wastes memory for analytics.
# MEMORY INTENSIVE - exact count
unique_visitors = HashSet() # 8 bytes per visitor
for event in events:
unique_visitors.add(event.user_id)
# 800 MB for 100M unique visitors
# MEMORY EFFICIENT - approximate count
hll = HyperLogLog.new(precision=14) # 16 KB total
for event in events:
hll.add(event.user_id)
# 16 KB with ±2% accuracy
When to fix: Analytics, dashboards, monitoring (where ±2% error acceptable).
Problem: Bloom filters don't support deletion; leads to false positives growing over time.
# WRONG - can't delete from Bloom filter
bloom = BloomFilter.new(1_000_000)
bloom.add("cached_item")
# Can't delete when cache invalidated!
# CORRECT - Cuckoo filter supports deletion
filter = CuckooFilter.new(capacity=1_000_000)
filter.add("cached_item")
filter.delete("cached_item") # Works!
When to fix: Cache tracking, rate limiting with expiration, any scenario requiring deletion.
Problem: Standard quicksort doesn't exploit CPU cache effectively.
# CACHE INEFFICIENT - many cache misses
standard_sort(large_list)
# CACHE EFFICIENT - block-wise processing
block_quicksort(large_list) # 1.5-2× faster
When to fix: Sorting >10K items on modern CPUs (post-2010).
Consider using the algorithms-researcher agent when:
Example Questions for Researcher:
| Algorithm Type | Description | Maturity |
|---|---|---|
| xxHash3/xxHash64 | Modern non-crypto hash | Stable |
| BLAKE3 | Fast cryptographic hash | Stable |
| HyperLogLog | Cardinality estimation | Stable |
| Bloom Filters | Standard membership testing | Stable |
| Cuckoo Filters | Membership with deletion | Beta |
| Count-Min Sketch | Frequency estimation | Write custom |
| B+ Trees | Persistent sorted data | Beta |
Consider custom implementation when:
For language-specific library recommendations:
references/elixir.md - NIFs, :atomics, ETSreferences/rust.md - crates ecosystemFor language-specific implementations of these algorithms:
references/elixir.md - Elixir libraries, NIFs, production patternsreferences/rust.md - Rust crates, zero-copy patterns, SIMDperformance-analyzer - For profiling and benchmarking optimizationsdistributed-systems - For consensus and replication algorithmsproduction-quality - For testing and documentation