Programming Fundamentals · Data Structures Behind AI

Check AI-Written Code Once Through

Three tiers: have AI explain the structure it picked, demand an alternate implementation and compare trade-offs, pick a way of organizing for your own project

THE QUESTION THIS PAGE ANSWERS

ANSWER FIRST

What is the key idea behind “Check AI-Written Code Once Through”?

Three tiers: have AI explain the structure it picked, demand an alternate implementation and compare trade-offs, pick a way of organizing for your own project

DECISION RULE

Follow the handoffs, not the demo. A system becomes dependable at the boundaries between model, tools, state, permissions, and people. Read each handoff as a place where you can observe, test, and recover.

TRY NEXT

Name the input, owner, approval, and recovery action for one automated step.

WATCH FOR

A successful run that cannot explain what happened or be safely repeated.

Pick a tier · start today
🥉

Task 1 · Make AI account for itself

First step of checking: don’t read the code—audit the confession

30 min

Grab a piece of code AI already wrote for you (don’t have one? Ask AI to write a small “contact-list dedupe” tool: take a pile of names + phone numbers, drop the duplicates). Then throw the prompt below at it and make it confess which way of organizing it used.

For the code you just wrote, answer three questions in plain language — I’m not a programmer: 1. What data structure did you use to store this data? (array, hash table, or something else?) 2. Why that one and not something else? Name at least one alternative you rejected and why; 3. If the data volume grows 1000× (say from 100 rows to 100,000), how much slower does this code get? Which line breaks first? If you realize your choice wasn’t actually optimal, say so honestly and give a better version.
Done when: you can retell in your own words “what structure it used, why, and what happens when data grows”—if you can’t retell it, chase AI for another round.
🥈

Task 2 · Demand a different organizer

Same feature, two implementations—you’re the judge of trade-offs

Half a day

Take Task 1’s code and have AI rewrite the same feature with a different data structure, then list a trade-off table for both versions. The key is the last step: don’t let AI deliver the verdict—you decide which version fits your scenario.

Please re-implement this same feature with a different data structure (e.g. if you used an array, switch to a hash table/Set; if you used a hash table, switch to an array), then: 1. Paste the full code for both versions, with comments on key lines explaining “what this line is doing”; 2. Make a trade-off table comparing at least four dimensions: lookup speed, insert speed, memory use, code readability; 3. Separately say: when version A is better, when version B is better, with one concrete example each (how much data, how frequent the ops); 4. Don’t decide for me — leave the judgment to me. My scenario is: (describe your real situation, e.g. “personal tool, a few hundred rows at most” or “shipping to tens of thousands of users”)
Done when: you picked based on your own scenario and can say “because my data volume is X and my most frequent op is Y, I pick this”—if you can’t say that sentence, AI still made the call for you.
🥇

Task 3 · Pick a structure for your own project

Choose yourself first, then compare answers with AI

1 week

Pick a real need on your plate (work project or personal tool—either’s fine). Don’t ask AI yet—use the “how do I look up / how do I get in and out” decision mantra from ds-summary and pick the data structure yourself; then let AI independently produce a selection plan and see whether you two agree. Run the self-check list below first so the scenario is clear before you start.

📋 Pre-selection self-check (tick all before asking AI)
How big will the data grow? Hundreds of rows now, or millions later—scale decides everything
Is the most frequent op lookup or insert? Read-heavy vs write-heavy → completely different answers
Do you need to keep order? If you need time / ranking order, many structures are out immediately
Do you need dedupe? Built-in uniqueness is Set / hash’s home turf
Is a cache worth it? If the same query keeps happening, think about ds-6’s invisible discount
🎉 All five questions clear—you’ve already done the step most engineers skip. Take these five answers to AI and the plan you get will be a tier higher.
I have a real need for data-structure selection. I’ve already picked myself. Don’t give the answer yet—follow this process: My need: (one-sentence description, e.g. an inventory lookup tool for the company’s 5000 SKUs) My scenario params: data volume ~X rows, most frequent op is X, need order?: X, need dedupe?: X, do the same queries repeat?: X Please: 1. Independently give your selection (what structure to store with, and why)—don’t ask what I picked yet; 2. Estimate performance under my data volume (roughly how fast one lookup / one insert is); 3. Say whether the plan must change when data grows 10×, and how. After you answer I’ll reveal my pick and we’ll compare: if we match, we cross-check; if not, we debate whose reasoning holds up better.
Done when: you and AI agree on the pick (cross-check success), or you disagree but you can follow its reasons and state yours in the debate—both endings count as a win; the failure mode is never having chosen yourself at all.
Why the order is “pick yourself first, then ask AI”? The other way around, AI’s answer instantly overwrites your thinking—you never learn what you would have chosen. Checking skill grows in the gap of “I picked differently from it—why?”
Also remember · three red-flag signals when checking

While doing the tasks, if you see these three signals in AI’s answers, chase one more round of questions.

🚩
Nested loops hunting for things

Two layers of for comparing one by one—that’s ds-1’s “big drawer inside a big drawer.” Ask once: “Would a Set / hash table be faster?”

🚩
Can’t name what it rejected

When you ask for alternatives it only praises the current pick and can’t name a rejected option—that means it never selected; it just defaulted.

🚩
Demo only on tiny data

A demo flying on 10 rows means nothing. Always ask: “What if data grows 1000×?”—the most valuable sentence in this chapter.

Why “Pick a tier · start today” depends on the operation

“First step of checking: don’t read the code—audit the confession” makes the structure concrete. The useful comparison is not which name sounds more advanced, but how the data is arranged and how far the most common operation has to travel.

Read a structure through access and change

“Grab a piece of code AI already wrote for you (don’t have one?” exposes a trade-off that is easy to miss: reading by position, looking up by key, adding at either end, inserting in the middle, and traversing relationships do not favor the same organization. A structure that is fast for one operation is not automatically fast for all of them.

  • Checking starts with auditing the confession : make AI account for structure, reasons, and alternatives—exposes problems faster than reading the code itself
  • You deliver the verdict : AI lays out facts and comparison tables; “which version fits my scenario” must be your call
  • Five questions before selecting : scale, read/write mix, order, dedupe, cache—clear these before asking AI and plan quality jumps a tier

Count scale and update frequency together

Use “A demo flying on 10 rows means nothing.” as a boundary check. Write down the data size, the dominant operation, and the latency you can accept before deciding whether an AI-generated structure actually fits.

From “Pick a tier · start today” to “Also remember · three red-flag signals when checking”

“Pick a tier · start today” grounds the problem in “First step of checking: don’t read the code—audit the confession”. “Also remember · three red-flag signals when checking” then moves it toward “While doing the tasks, if you see these three signals in AI’s answers, chase one more round of questions”. Together, they show that the lesson is not just a conclusion to remember, but a claim with conditions.

Carry the judgment into the next situation

When you meet a new data structure, do not begin by memorizing its definition. Write down the most frequent operation, estimate scale and update behavior, and check whether the structure satisfies all three conditions.

  • “Pick a tier · start today”: First step of checking: don’t read the code—audit the confession
  • “Also remember · three red-flag signals when checking”: While doing the tasks, if you see these three signals in AI’s answers, chase one more round of questions
  • “The closing point”: Pick first, then compare answers : checking eyesight grows in the gap where you and AI disagree

The final “The closing point” brings the discussion to “Pick first, then compare answers : checking eyesight grows in the gap where you and AI disagree”. The useful thing to carry forward is knowing which judgments must be revisited when input, scale, or risk changes.

✅ What this lesson wants to share

  • Checking starts with auditing the confession: make AI account for structure, reasons, and alternatives—exposes problems faster than reading the code itself
  • You deliver the verdict: AI lays out facts and comparison tables; “which version fits my scenario” must be your call
  • Five questions before selecting: scale, read/write mix, order, dedupe, cache—clear these before asking AI and plan quality jumps a tier
  • Pick first, then compare answers: checking eyesight grows in the gap where you and AI disagree
Mark as learned Your reading progress updates automatically
← PreviousNext →

Keep reading

The next useful article in the thread.

ARTICLE DISCUSSION

Leave one useful thought here.

Keep the idea that clicked, the question that stayed open, or a small note for the next learner.

Discussing Check AI-Written Code Once Through Data Structures Behind AI
3discussionsArticle discussion · synced with the Circle
View in the learning circle
AM
Asha MorganContent editor
INSIGHTField note

I turned one judgment from this article into a small experiment I could run today. Knowing what to observe next is more useful than simply remembering the conclusion.

ARTICLE DISCUSSION7 helpful
LH
Lin HarperIndie developer
INSIGHTInsight

After reading this, I first looked for the conditions behind the idea instead of copying the method into a project. That order made the later trade-offs much clearer.

ARTICLE DISCUSSION5 helpful
KM
Kiki MooreProduct operations
QUESTIONQuestion

When this judgment reaches real work, which constraint should be added first? I am curious which step matters most between reading and the first practical attempt.

ARTICLE DISCUSSION4 helpful