Coding
AI Prompt for Comparing Algorithms
Compare algorithm approaches with this AI prompt: side-by-side complexity, trade-offs and a clear recommendation for your specific constraints.
The prompt
Role: You are an algorithms consultant who makes build-vs-build decisions with data. Context: Problem: [PROBLEM]. Candidate approaches: [CANDIDATES]. Context: [CONTEXT: data size, characteristics, what matters most]. Task: 1) Build a comparison table: approach | time complexity | space complexity | best when | worst when | implementation effort. 2) Analyze each against [CONTEXT] specifically — which constraints favor which approach. 3) Give a clear RECOMMENDATION with the decisive reasons (not "it depends" — decide). 4) Note the hybrid option if combining approaches beats any single one. 5) State what would change your recommendation (the sensitivity analysis). Format: Comparison table first, then per-approach analysis, then the recommendation, then the sensitivity note. Ask the AI to re-run the comparison under a 10x scale projection: which winner survives growth and which collapses. Today's best choice is often tomorrow's bottleneck. Constraints: Decide — hedge only where genuinely uncertain, and say why. Ground complexity claims in [CONTEXT]'s actual numbers, not abstract n.
Variables to fill in
Replace each [variable] in the prompt with your own details:
[PROBLEM] [CANDIDATES] [CONTEXT]
Example input
PROBLEM=shortest path in unweighted graph, CANDIDATES=BFS vs Dijkstra vs DFS, CONTEXT=10k nodes, need shortest path length only
How to use this prompt
Name the candidates you are considering — the comparison is sharper than open-ended brainstorming. Define the decision criteria (speed, memory, simplicity) upfront.
Tips for the best results
- Ask for the sensitivity analysis — knowing when the answer flips is powerful.
- Have it estimate real runtimes from your data size, not just Big-O.
- Request the hybrid option; real systems often combine approaches.
Frequently asked questions
Will it just say 'it depends'?
It compares on YOUR context (graph size, weights, what you need) and picks the winner with reasons — no generic advice.
Can Big-O alone decide between algorithms?
No — constants, memory, and implementation risk matter at real scales. This prompt's matrix forces all of them onto the table before deciding.