Prompt lesson · 18 prompts
Algorithm Optimization prompts for Software Developers
18 ready-to-use prompts from our AI for Software Developers course. Copy one, fill in the {{placeholders}}, and paste it into ChatGPT, Claude, Gemini or any other AI.
Algorithm Parameter Tuning
Use this when you need to fine-tune algorithm parameters for optimal performance, whether for machine learning models, search algorithms, or other computational systems.
Role – You are an algorithm optimization expert who helps developers systematically tune parameters to improve performance, accuracy, or efficiency of their algorithms.
Context you provide
- {{algorithm_type}} – the type of algorithm (e.g., decision tree, neural network, sorting, search, recommendation)
- {{performance_goal}} – what you want to optimize (e.g., speed, accuracy, memory usage, F1-score)
- {{current_parameters}} – optional: current parameter set and their values
- {{data_or_use_case}} – optional: description of the data or use case (e.g., real-time predictions, batch processing)
Instructions
- Ask for missing information, especially algorithm type and performance goal. If not provided, ask the user to clarify.
- Based on the algorithm type, list the most important parameters that typically affect performance, explaining the impact of each.
- Provide a step-by-step approach to tuning, including whether to use manual search, grid search, random search, or Bayesian optimization.
- Suggest appropriate parameter ranges or starting values, and recommend libraries (e.g., Scikit-learn’s GridSearchCV, Optuna, Hyperopt) that can automate the process.
- Explain how to evaluate different configurations using cross-validation or other robust methods, and how to avoid overfitting.
- If the user provides current parameters, analyze them and suggest changes or next steps.
Output format – A structured guide with sections: Key Parameters, Tuning Strategy, Recommended Tools, Evaluation Method. Use tables for parameter ranges. Tone: technical and precise.
Guardrails – Do not generate code that could harm the system or violate security best practices. Provide general strategies; specific parameter values may depend on the data, which you cannot access. Flag assumptions about the algorithm’s environment (e.g., memory limits).
Example – {{algorithm_type}} = “Random Forest classifier”; {{performance_goal}} = “maximize accuracy while keeping inference time under 100ms”; {{current_parameters}} = “n_estimators=100, max_depth=None, min_samples_split=2”
Open this prompt Analysis · Advanced
Algorithmic Complexity Analysis and Optimization
Use this when you need to analyze time and space complexity of an algorithm and identify performance bottlenecks.
Role You are a computer science expert specializing in algorithm analysis. Your goal is to help developers understand the time and space complexity of their algorithms and suggest optimizations to improve performance.
Context you provide
- {{Algorithm or code snippet}} – The code or pseudocode you want analyzed (e.g., a sorting function, a search algorithm, a recursive function).
- {{Language}} – Programming language used (e.g., Python, Java, C++).
- {{Expected input size}} – Typical size of input data (e.g., 10, 10^6, variable).
- {{Current performance issues}} – Any specific problems you're facing (e.g., slow on large datasets, memory spikes).
Instructions
- Ask for any missing context before starting.
- Analyze the algorithm's time complexity (Big-O) and space complexity (Big-O) based on the provided code.
- Identify bottlenecks and explain why they cause performance issues.
- Suggest specific optimizations, including alternative algorithms or data structures, with trade-offs.
- If applicable, provide code snippets for the optimized version.
Output format A clear analysis with sections: Complexity Analysis, Bottleneck Identification, and Optimization Recommendations. Use Big-O notation, bullet points, and code blocks. Keep it detailed but concise (300–400 words).
Guardrails
- Do not change the algorithm's core logic without explaining the trade-offs.
- Flag any assumptions about input characteristics (e.g., worst-case, average-case).
- Stay within the scope of complexity analysis; do not provide unrelated code review.
Example {{Algorithm}}: quicksort implementation in Python; {{Language}}: Python; {{Expected input size}}: up to 10^6; {{Current performance issues}}: slow when input is nearly sorted.
Open this prompt Analysis · Advanced
Algorithmic Trade-Off Analysis
Use this when you need to analyze time versus space complexity trade-offs and recommend the best optimization strategy for a given algorithmic task.
Open this prompt Analysis · Intermediate
Analyze Algorithm Efficiency
Use this when you need to evaluate the efficiency of an algorithm, compare it to alternatives, and identify improvements.
Open this prompt Analysis · Intermediate
Design Approximation Algorithms for Complex Problems
Use this when you need to create algorithms that deliver near-optimal solutions quickly, balancing accuracy and computational efficiency.
Open this prompt Creating · Advanced
Design Heuristic Algorithms for Complex Problems
Use this when you need to design or explain heuristic algorithms that provide approximate solutions to complex problems, reducing computation time.
Open this prompt Creating · Intermediate
Evaluate Space Complexity
Use this when you need to assess and optimize the memory usage of an algorithm or data structure.
Open this prompt Analysis · Intermediate
Evaluate Time Complexity
Use this when you need to analyze the runtime efficiency of an algorithm and find ways to improve it.
Open this prompt Analysis · Intermediate
Evaluating AI-Generated Code
Use this when you need to evaluate code or optimizations suggested by an AI tool, focusing on best practices, performance, security, and maintainability.
Open this prompt Analysis · Advanced
Identify Redundant Computations
Use this when you need to find and eliminate unnecessary calculations in your code to improve performance.
Open this prompt Analysis · Intermediate
Implement Genetic Algorithm for Optimization
Use this when you need to design and implement a genetic algorithm to solve a complex optimization problem.
Open this prompt Coding · Intermediate
Memory Optimization Strategies for Software
Use this when you need to reduce memory usage in your application while maintaining performance.
Open this prompt Coding · Advanced
Optimize Data Structures
Use this when you need to improve the performance of your code by selecting and optimizing data structures for faster lookups and searches.
Open this prompt Analysis · Intermediate
Optimize Memory Management
Use this when you need to reduce memory usage, manage object lifecycles, or improve garbage collection in your application.
Open this prompt Analysis · Intermediate
Optimize Resource Utilization
Use this when you need to improve CPU, memory, or I/O efficiency through techniques like caching and lazy loading.
Open this prompt Analysis · Intermediate
Optimize Sorting Algorithms
Use this when you need to select or improve a sorting algorithm based on your data size, distribution, and performance requirements.
Open this prompt Analysis · Intermediate
Parallelize Computations
Use this when you need to improve algorithm performance by leveraging multi-core processors through parallel computing.
Open this prompt Planning · Advanced
Profile and Optimize Algorithms
Use this when you need to identify performance bottlenecks in an algorithm and get recommendations for optimization.
Open this prompt Analysis · Advanced