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

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

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

Before Sorting: What Are We Ordering?

Define the required order, look inside a comparison, and choose an algorithm that fits the data and memory limits.

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

One Task, Several Sorting Algorithms

Goal: Describe the required result before choosing the steps that produce it.

Sorting means putting items in a chosen order. In ascending order, smaller values come first. In descending order, larger values come first. The key is the value we compare to decide which item should come first.

An algorithm must produce that order and keep all the original items. Losing an item is not a correct sorting method, even if the remaining items look ordered. Repeated values must keep their correct number of occurrences.

Several algorithms solve this same task. In the next lesson, we will follow Selection Sort and Insertion Sort one move at a time. First, learn how to describe the task and its constraints; you do not need to memorise a long list of algorithm names.

A map of names, not a ranking
GroupExamplesWhat to notice now
Direct comparison methodsSelection Sort, Insertion SortSimple steps; the usual versions have quadratic worst-case time
Other comparison methodsMerge Sort, Quick Sort, Heap SortTheir guarantees depend on the algorithm and the case being analysed
Other names you will meetBubble Sort, Comb Sort, Shell SortA similar name does not imply the same running time
Distribution methodsCounting Sort, Radix Sort, Bucket SortThese use properties of the values, their digits, or their distribution

There is no rule that every algorithm in one row is always better than every algorithm in another row. For example, ordinary Quick Sort can take quadratic time in the worst case; O(nlog⁡n)O(n\log n) is not a guarantee for every execution of every version.

Remember: Sorting is the task. Selection Sort and Insertion Sort are different ways to do that task.

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

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

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

نسبة الدفتر إلى الدكتور غير مؤكدة. أمثلة Ali5/Ali7 و123/127 محفوظة. نجعل افتراض كلفة المقارنة واضحًا، ولا نعمّم خطية Distribution Sort دون شروط. فقرة أقصر طريق وشجرة التكلفة تميّز المسألتين دون نسب شرح غير متاح. لا توجد في البنك الحالي أسئلة سنوات مناسبة مباشرة لهذا الدرس.

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