Skip to content
PromptLab by FEHMER TECH
ENDE
Coding

Algorithm Optimization

Optimize your algorithms for better time complexity and memory efficiency.

Prompt template

Analyze and optimize the following algorithm in [PROGRAMMING LANGUAGE]:

**Current Algorithm:**
```[PROGRAMMING LANGUAGE]
[INSERT CODE HERE]
```

**Context:**
- Input size: [EXPECTED DATA SIZE]
- Current performance issues: [DESCRIPTION]
- Constraints: [MEMORY/TIME LIMITS]

**Please provide:**
1. **Complexity Analysis:** Current time and space complexity (Big-O notation)
2. **Bottlenecks:** Identify performance bottlenecks
3. **Optimized Algorithm:** Improved version with explanation
4. **New Complexity:** Time and space complexity of the optimized algorithm
5. **Trade-offs:** What compromises exist (e.g., more memory for less time)?
6. **Benchmarks:** Estimated improvement with concrete numbers
7. **Alternative Approaches:** If fundamentally different solution strategies exist

Explain each optimization step and why it improves performance.

Replace placeholders in [square brackets]: [PROGRAMMING LANGUAGE][INSERT CODE HERE][EXPECTED DATA SIZE][DESCRIPTION][MEMORY/TIME LIMITS]

How to use this template

Copy the prompt, replace the placeholders in square brackets with your details and paste it into the AI assistant of your choice. The more precise your details, the better the result.

Tips for better results

  • Specify the expected input size for appropriate optimizations
  • Mention memory or time constraints from your environment
  • Ask for complexity visualizations
  • Request comparison tests between original and optimized versions

Suitable open models

The selection names current open models as a starting point for your own tests. It is not a measurement for this template.

Keywords: #algorithms #optimization #performance #big-o

Last updated: