كل الأمثلة

أمثلة

الترتيب السريع بلغة Python، تبديلًا بعد تبديل

سبعة أعداد تُرتَّب حول محور: كل مقارنة وكل تبديل بجانب سطر Python الذي يقوم به، ثم المقارنات الـ10 في هذا التشغيل على رسم النمو.

صُنع هذا الفيديو بمهارة الخوارزميات المرئية.

  • 1:05
  • الخوارزميات المرئية
  • بصوت Charon
  • الإنجليزية

صُنع من فكرة

Quick sort on 8, 3, 6, 1, 9, 2, 5, step by step in Python

التفريغ النصي للفيديو

How can you sort these numbers without repeatedly finding the smallest?

These 7 numbers need sorting. Through i, values stay at most the pivot. Orange marks executing code; green means done.

Line 8 picks pivot 5. Line 11 leaves 8 right because it exceeds 5.

3 belongs left. Which number will it swap with?

3 swaps with 8; 1 and 2 also move left because neither exceeds 5.

5 lands between the sides, permanently placed.

Recursion partitions the left around 2; single numbers need no sorting.

8 separates 6 and 9; the pivot rule now holds everywhere. Worst-case work is quadratic.

The chart marks 10 comparisons for 7 numbers; average work grows as n log n.

Partition, then sort each side: that's how you order the numbers.

موضوعك، مرسومًا في دقيقة تقريبًا.

أول 2 من فيديوهاتك مجانًا، مدة كلٍّ منها حتى دقيقة واحدة، مع علامة مائية. لا حاجة إلى بطاقة دفع. المنتج كاملًا، بكل الأصوات والأساليب.