Coding
AI Prompt for Structure Trade-offs
Compare data structures head-to-head with this AI prompt: trade-off matrix on your workload, cache and memory analysis, and a conditional winner.
The prompt
Role: You are a systems engineer who chooses data structures by measured trade-offs, not hype. Context: Candidates: [CANDIDATES]. Workload: [WORKLOAD_MIX]. Data size: [DATA_SIZE]. Language: [LANGUAGE]. Task: 1) Build a trade-off matrix: candidate × (point lookup, range scan, insert, delete, memory overhead, cache friendliness, implementation risk). 2) Analyze each cell for MY workload — e.g. "range scans are 10% so the B-tree's scan advantage matters little." 3) Give a conditional recommendation: "Choose X IF [condition], else Y." 4) Quantify memory at [DATA_SIZE] roughly per candidate. 5) Name the experiment that would settle any remaining doubt (benchmark design). Format: Matrix first, then per-candidate analysis, then the conditional recommendation, then memory estimates, then the benchmark design. Ask the AI to redo the matrix for your projected scale in two years, not just today's. Structures chosen for current size often become the scaling bottleneck you predicted too late. Constraints: No generic "X is faster" claims — tie every claim to [WORKLOAD_MIX]. Include cache/memory effects; Big-O alone misleads at scale. The benchmark design must be runnable.
Variables to fill in
Replace each [variable] in the prompt with your own details:
[CANDIDATES] [WORKLOAD_MIX] [DATA_SIZE] [LANGUAGE]
Example input
CANDIDATES=hash map vs B-tree vs sorted array, WORKLOAD=90% point lookups, 10% range scans, 50M keys, LANGUAGE=Rust
How to use this prompt
Give the workload split as percentages — trade-offs only make sense against a real mix. Include data size; cache effects change the answer at scale.
Tips for the best results
- Fill in your real workload percentages — guesses produce generic answers.
- Ask for the memory math; it often decides between close candidates.
- Run the suggested benchmark before committing to an exotic choice.
Frequently asked questions
Does it pick a winner?
It builds the trade-off matrix on YOUR workload numbers, then gives the conditional recommendation — the format forces a real decision.
Do cache effects really change the answer?
At scale, yes — a cache-friendly O(n) scan can beat a pointer-chasing O(log n) tree. The prompt's matrix includes cache behavior for this reason.