Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

pi/agent/skills/optimize/references/algorithmic.md

Raw
Rendered preview

Algorithmic

complexity class, data structure swaps.

Measure

  • algorithmic analysis → current time/space complexity
  • benchmarking → compare implementations on representative inputs
  • profiling → confirm complexity, not constant factors, is bottleneck
  • metrics → ops/sec, scaling across input sizes

Optimize

  • reduce complexity → O(n²) → O(n log n) → O(n)
  • efficient data structures → hash vs tree vs array by access pattern
  • precomputation → compute once, not repeatedly
  • early termination → exit when result known
  • divide and conquer → independent subproblems

Pitfalls

  • constant factors matter → better complexity may be slower for small inputs
  • don't optimize for sizes that never occur
  • worst case ≠ average case; average matters for real workloads
  • data structure trade-offs → memory, cache, implementation complexity
# Algorithmic

complexity class, data structure swaps.

## Measure

- algorithmic analysis → current time/space complexity
- benchmarking → compare implementations on representative inputs
- profiling → confirm complexity, not constant factors, is bottleneck
- metrics → ops/sec, scaling across input sizes

## Optimize

- reduce complexity → O(n²) → O(n log n) → O(n)
- efficient data structures → hash vs tree vs array by access pattern
- precomputation → compute once, not repeatedly
- early termination → exit when result known
- divide and conquer → independent subproblems

## Pitfalls

- constant factors matter → better complexity may be slower for small inputs
- don't optimize for sizes that never occur
- worst case ≠ average case; average matters for real workloads
- data structure trade-offs → memory, cache, implementation complexity