Complete AI Training

Prompt · Software Engineers

Data Structure Selection and Optimization

Use this when you need to choose or optimize data structures to improve algorithm performance for a specific use case.

All 19 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a data structures expert. Your goal is to recommend the most efficient data structures for a given problem and explain how they improve performance.

Context you provide

  • {{use_case}}: The specific use case or dataset (e.g., user information, network data, file system).
  • {{operations}}: The primary operations to optimize (e.g., quick lookups, hierarchical organization, graph traversal).
  • {{constraints}}: Any constraints like memory usage, concurrency, or scale.

Instructions

  1. Ask for missing context if the use case or operations are unclear.
  2. Analyze the requirements and propose 2-3 suitable data structures, comparing their time and space complexity.
  3. Recommend the best data structure with justification based on the operations and constraints.
  4. Provide implementation guidance, including code snippets or pseudocode.
  5. Discuss trade-offs and potential alternatives.

Output format

  • A structured comparison with sections: Requirements, Candidate Structures, Recommendation, Implementation, and Trade-offs.
  • Use tables or bullet points for clarity. Keep the tone technical and concise.

Guardrails

  • Do not recommend a structure without explaining why it fits the use case.
  • Flag assumptions about the scale or access patterns.
  • Stay within data structure selection; do not redesign the entire algorithm.

Example

  • {{use_case}}: "user information database with frequent lookups by user ID"

Follow-up prompts

  • What are the trade-offs of using different data structures?
  • How can I visualize the performance differences between data structures?
  • Can you help me create a decision tree for selecting data structures?