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
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
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
Design a Versioned API
Evolving a public API without breaking integrations
Create a CLI Tool with Node.js
Create a professional Node.js CLI tool with Commander.js, Inquirer, visual feedback, and npm publishing.
Sora Prompt for Generating JavaScript Code
Sora, developed by OpenAI, is a versatile artificial intelligence model that can be used to assist in various creative and technical tasks, including JavaScript code generation. Although Sora is primarily known for its video generation capabilities, its integration into the OpenAI ecosystem allows you to leverage its text features to produce functional code snippets. By crafting precise and structured prompts, you can obtain clean, commented, and ready-to-use JavaScript code for your web projects. Whether you need utility functions, interactive components, or complete scripts, the key lies in the quality of your prompt. A well-constructed prompt should specify the usage context, technical constraints, desired code style, and edge cases to handle. In this guide, we offer optimized prompts to get the most out of Sora for JavaScript code generation, with variants suitable for all expertise levels. Discover how to structure your requests to obtain reliable, maintainable code that meets modern web development standards.
Write Storybook stories
Document components in Storybook