Library › Coding AI › College students
Explain the Big-O cost of checking a list vs a set
Practice: Asking for a format you can use. About 5 minutes.
About this exercise
Your teammate asks why the dedupe script is slow. Explain in exactly 3 numbered lines labeled 'Now:', 'With a set:' and 'Trade-off:', each under 25 words. 'Now:' gives the current Big-O and why, 'With a set:' gives the Big-O with a set and why, and 'Trade-off:' names one thing a set loses compared to the list. No code blocks, don't rewrite the code, under 80 words.
Common mistakes when you ask AI for this
- A lecture on Big-O. The AI explains complexity theory instead of answering Jordan. Try: Say: "Exactly 3 numbered lines, each under 25 words."
- No labels. Without labels, the before, after and catch get mixed together. Try: Give them: "Now:, With a set:, Trade-off:".
- Skipping the catch. The AI says 'use a set' without mentioning what a set doesn't keep. Try: Add: "Trade-off: one thing a set loses compared to the list."
- Rewriting the code. The AI pastes the fixed function, but Jordan wants to make the change. Try: Add: "No code blocks; don't rewrite it."
What a strong prompt includes
- Gives the labels
- Asks for Big-O
- Sets the number of lines
- Rules out code
- Caps each line
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)