Analyze Your Code Algorithmic Complexity Like an Expert
This prompt provides a complete analysis of source code algorithmic complexity, with Big O notation, bottleneck identification and concrete optimization recommendations.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un expert en algorithmique et en analyse de complexité computationnelle. Analyse en profondeur la complexité algorithmique du code suivant :
[CODE_A_ANALYSER]
Contexte d'utilisation : [CONTEXTE] (ex : traitement de données massives, application temps réel, script ponctuel...)
Pour chaque fonction ou bloc logique significatif, fournis :
-
Complexité temporelle (Time Complexity) :
- Notation Big O dans le pire cas (worst case)
- Notation Big Omega dans le meilleur cas (best case)
- Notation Big Theta pour le cas moyen (average case)
- Justification ligne par ligne des boucles, récursions et appels imbriqués
-
Complexité spatiale (Space Complexity) :
- Mémoire auxiliaire utilisée (hors input)
- Structures de données temporaires créées
- Profondeur de la pile d'appels si récursion
-
Identification des goulots d'étranglement :
- Quelles parties du code dominent la complexité globale ?
- Y a-t-il des opérations cachées coûteuses (ex : copie de liste, concaténation de chaînes, tri implicite) ?
-
Recommandations d'optimisation :
- Propose une version optimisée du code avec une meilleure complexité
- Explique le compromis temps/espace (time-space tradeoff) de chaque alternative
- Indique les structures de données plus adaptées si pertinent (hash map, heap, arbre équilibré...)
-
Tableau récapitulatif :
Présente un tableau comparant la version actuelle et la version optimisée (complexité temporelle, spatiale, et comportement estimé pour n = 100, 10 000 et 1 000 000 éléments).
Adapte ton niveau d'explication à un développeur de niveau [NIVEAU] (débutant / intermédiaire / avancé).
Personalize this prompt with Léa
Answer 3 questions and Léa tailors the prompt to your situation.
Why this prompt works
<p>This prompt transforms the AI into a rigorous algorithmic analyst. By providing your code and its usage context, you get a methodical breakdown of its time and space complexity, with all three standard notations (Big O, Big Omega, Big Theta).</p><p>The <strong>[CONTEXT]</strong> variable is essential: an O(n squared) algorithm may be perfectly acceptable for a one-off script on 50 elements, but catastrophic for real-time processing on millions of records. The <strong>[LEVEL]</strong> variable adapts the explanations — a beginner will receive analogies and step-by-step diagrams, while an advanced developer will get references to complexity classes and formal proofs.</p><p><strong>Usage tip:</strong> for optimal results, include the complete code (not just a snippet) and specify your environment constraints (limited memory, maximum acceptable latency). The AI can then propose time/space tradeoffs truly suited to your situation.</p>
Use Cases
Expected Output
A structured analysis including detailed time and space complexity of each code block, a diagnosis of the most expensive parts, an optimized version with tradeoff explanations, and a comparative table of estimated performance at different input sizes.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Pour des résultats précis, explicitez toujours le contexte (volume de données, contraintes temps réel) et le niveau du développeur dans le prompt. Cela permet au modèle d’adapter ses recommandations de trade-off mémoire/temps au cas concret.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Cache Optimization in Pipelines
Speed up CI/CD pipelines
Optimize bundle size
Reduce JavaScript bundle size
Namespace and Quota Management
Manage a multi-tenant cluster
GitHub Copilot Prompt for Generating SQL Queries
GitHub Copilot is radically transforming how developers write SQL queries on a daily basis. Integrated directly into your code editor, this AI assistant understands your project context — table schemas, entity relationships, naming conventions — to generate precise and optimized SQL queries. Whether you work with PostgreSQL, MySQL, SQL Server, or SQLite, Copilot adapts to the specific syntax of your database engine. The challenge is not just to generate functional SQL, but to obtain performant, readable, and maintainable queries. A well-structured prompt enables Copilot to produce complex joins, correlated subqueries, window functions, and aggregation queries that follow best practices. By providing your table schema, expected output, and performance constraints, you get production-ready queries rather than drafts that need reworking. This guide offers an optimized main prompt as well as variants suited to your skill level, to fully leverage Copilot in generating reliable and performant SQL queries.