# Algorithmic Efficiency

> A design rule that an algorithm and its data structures are chosen for how their cost grows with input size.

Record: `architecture:algorithmic-efficiency`
Kind: principle
Layer: [Performance Core](https://banes-lab.com/records/layer/performance-core.md)
Severity: contextual
Scope: algorithm, data structure
Canonical: https://banes-lab.com/ontology#architecture-algorithmic-efficiency

Listed in [Architecture principles](https://banes-lab.com/api/records/architecture.md), after [Performance Engineering](https://banes-lab.com/records/architecture/performance-engineering.md) and before [Time Complexity](https://banes-lab.com/records/architecture/time-complexity.md).

## Repair

- Refactored by: Replace Algorithm, Add Index, Change Data Structure
- Detected by: complexity analysis, benchmark slope
- Violated by: avoidable quadratic/exponential behavior
- Measured by: time/space complexity
- Enforced by: [review](https://banes-lab.com/records/lexicon/review.md), benchmarks

## Requires

- [Complexity Awareness](https://banes-lab.com/records/lexicon/complexity-awareness.md)

## Reinforces

- [Scalability](https://banes-lab.com/records/architecture/scalability.md)

## Enables

- [Efficient Processing](https://banes-lab.com/records/lexicon/efficient-processing.md)

## Conflicts with

- [Inefficient Algorithm Choice](https://banes-lab.com/records/lexicon/inefficient-algorithm-choice.md)
- [N Plus One Query](https://banes-lab.com/records/architecture/n-plus-one-query.md)

## In tension with

- [Implementation Simplicity](https://banes-lab.com/records/lexicon/implementation-simplicity.md)

## Tensions

- [Algorithmic Efficiency / Implementation Simplicity](https://banes-lab.com/records/tension/algorithmic-efficiency-implementation-simplicity.md)

## Severity

- [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)

## Category

- [Scalability / Performance / Optimization](https://banes-lab.com/records/architecture-category/scalability-performance-optimization.md)

## Enforced by

- [rules/eslint/no-linear-scan-lookup.eslint.rule.ts](https://banes-lab.com/source/governance/rules/eslint/no-linear-scan-lookup.eslint.rule.ts.md)

## Reinforced by

- [Time Complexity](https://banes-lab.com/records/architecture/time-complexity.md)
- [Big O Notation](https://banes-lab.com/records/architecture/big-o-notation.md)

## Linked from

- [Anti-patterns](https://banes-lab.com/ontology/principles/architecture-category-anti-patterns.md)
- [Scalability / Performance / Optimization](https://banes-lab.com/ontology/principles/architecture-category-scalability-performance-optimization.md)
- [Scalability / Performance / Optimization](https://banes-lab.com/ontology/lexicon/lexicon-category-scalability-performance-optimization.md)
- [Severity levels](https://banes-lab.com/ontology/schema/the-vocabulary-severity.md)
- [The resolutions](https://banes-lab.com/ontology/schema/the-resolutions.md)
