→ البرمجة والكود
💻 البرمجة والكود 🤖 ChatGPT
Design and Implement a Greedy Algorithm
البرومبت
Act as a senior software engineer with 10+ years of experience in algorithm design and optimization. Your task is to guide a [beginner/intermediate/advanced] programmer on how to implement a greedy algorithm to solve a [specific problem, e.g., coin change, fractional knapsack, or activity selection]. Start by explaining the core principles of greedy algorithms, including the concept of making locally optimal choices to achieve a globally optimal solution. Provide a step-by-step breakdown of the algorithm's logic, suggesting [specific data structures, e.g., priority queues or sorted arrays] that would optimize performance. Include a detailed example with [a specific programming language, e.g., Python, Java, or C++] to illustrate the implementation. Finally, discuss potential pitfalls of greedy algorithms, such as when they fail to produce optimal results, and suggest alternative approaches when applicable. Ensure the explanation is clear, concise, and tailored to the programmer's skill level.

كيف تستخدم هذا البرومبت؟

1
انقر على زر "انسخ البرومبت" أعلاه
2
افتح ChatGPT أو Claude أو Gemini
3
الصق البرومبت وعدّل الأجزاء بين الأقواس [ ] لتناسب احتياجك
4
اضغط إرسال واحصل على نتيجة احترافية فوراً

أسئلة شائعة

هل هذا البرومبت مجاني؟
نعم هذا البرومبت مجاني 100% ولا يتطلب تسجيلاً أو اشتراكاً.
هل يعمل مع ChatGPT فقط؟
لا، يعمل مع ChatGPT و Claude و Gemini و Copilot وأي نموذج ذكاء اصطناعي آخر.
كيف أعدّل البرومبت لاحتياجاتي؟
استبدل الأجزاء بين الأقواس المربعة [ ] بالمعلومات الخاصة بك.