<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,700;12..96,800&family=DM+Sans:wght@400;500;600;700&family=Jost:wght@300;400;500;600;700&family=Sora:wght@600;700;800&family=Syne:wght@600;700;800&display=optional">

هذه الملخصات متاحة حاليًا باللغة الإنجليزية.

علوم الحاسوب الإعدادي

What is an algorithm and how do you write one?

كتبه وراجعه مدرّسو Studoli · آخر تحديث

الإجابة المختصرة

An algorithm is a precise, step-by-step set of instructions for solving a problem. It can be written in plain English, as pseudocode or as a flowchart, and then turned into a program. Good algorithms use three building blocks: sequence (steps in order), selection (if/else decisions) and iteration (loops).

خطوة بخطوة

  1. Decide the inputs and the expected output.
  2. Break the problem into small steps in the right order.
  3. Use selection for decisions: IF ... THEN ... ELSE.
  4. Use iteration to repeat steps: FOR or WHILE loops.
  5. Trace through the algorithm with test data to check it works.

مثال محلول

Pseudocode: find the largest of a list of numbers

  • largest ← first number
  • FOR each number in the list
  • IF number > largest THEN largest ← number
  • ENDFOR
  • OUTPUT largest

أخطاء شائعة

  • Writing vague steps such as "work out the answer".
  • Forgetting to initialise a variable before a loop.
  • Loops that never end because the condition never becomes false.

مفيد لـ:GCSEKS3IGCSEBac

الدرس الخصوصي هو أسرع طريقة لسد الثغرات قبل الامتحان. الدرس الأول مجاني.

ابحث عن مدرّس علوم الحاسوب

ملخصات ذات صلة

كل ملخصات علوم الحاسوب

الرسائل

يرجى تسجيل الدخول لإرسال الرسائل.

تحدّث معنا