العودة إلى الدراسة

المحاضرة 1 من 10

25 دقيقة تقريبًا

Algorithms: What They Do and How We Compare Them

Start with the required answer, then learn to compare work and read Big O without confusing it with an exact count.

تصفّح الدفتر
Step 1 of 7 · Understand

One problem, several algorithms

Goal: State what goes in and what must come out.

Suppose we want the average of three numbers. The three numbers are the input: the data we start with. Their average is the output: the result we must produce.

An algorithm is a clear set of steps that produces the required output and finishes for every input allowed by the problem. We can describe the steps in words before writing any C++ or Java.

There might be three different solutions: Algorithm A, Algorithm B, and Algorithm C. Before comparing their speed, ask: Do all three solve the same problem under the same conditions?

A small check before comparing solutions

A method that adds the three numbers but returns only their sum does not yet calculate their average. It must also divide the sum by 3. Finishing quickly does not make an incomplete answer correct.

This check separates the required result from the method used to produce it.

Quick check · predict, then try

Is an algorithm just its code?

You describe a solution in words, then write it in C++. What can stay the same when you implement it in Java?

Choose your prediction

Remember: An algorithm needs clear steps, the correct result, and a stopping point.

موضعك محفوظ تلقائيًا
مصادر الدرس وملاحظات المراجعة

يعتمد ترتيب الموضوعات والأمثلة على صفحات 4–8 من الدفتر. نسبة الدفتر إلى الدكتور غير مؤكدة. الشرح والتفاعلات التعليمية صياغة مساعدة، وليست نقلًا حرفيًا.

شرح عربي مساعد يعتمد ترتيب الموضوعات والأمثلة في الدفتر المستلم. المصدر الأصلي محفوظ، وتفاصيل التصحيحات والإضافات في ملاحظات المراجعة. لا يوجد دليل يؤكد اسم الدكتور أو مطابقة محاضرات الدفتر للتسجيلين.

نسبة الدفتر إلى الدكتور غير مؤكدة. صياغة الشرح والأنشطة تعليمية مساعدة. للتدقيق: نفصل Big O عن worst case وعن العدد الدقيق للعمليات، وlittle-o عن best case. الحسابات راجعت مستقلاً، أما مطابقة كل رمز في المصدر فلم تعتمد نهائيًا.

تصفّح صفحات هذا الدرس من الدفتر
خطوة صغيرة. فهم أعمق.ألجولاب · دفتر شخصي للدراسة