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

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

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

Quick Sort: Put a Pivot in Its Place

Follow the two original partition traces, finish the pivot swap, and see why balanced splits matter.

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

Choose a value, not a midpoint

Goal: Define what partition must produce.

Start with [7,9,12,6,3,1,10,2]. Choose the first value, 7, as the pivot. We want values ≤ 7 on the left and values > 7 on the right, with the chosen pivot between them.

This is partitioning. It does not promise that either side is sorted. Unlike Merge Sort, the split is based on value comparisons, not a fixed midpoint. Its size depends on the chosen pivot and the data.

Our convention sends other values equal to the pivot to the left. Other valid partition schemes use different rules; do not mix their boundaries or trace steps with this one.

Remember: Partition fixes a pivot position but leaves both sides to be sorted.

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

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

شرح تكميلي بالإنجليزية والعربية يتبع أمثلة وترتيب محاضرة الدفتر8 في صفحات PDF66–75. المصدر محفوظ وغير مؤكد النسبة لدكتور الطالب. الكود التكميلي وتصحيحات الادعاءات مفحوصة بصورة منفصلة؛ ليست اقتباسات من الأستاذ.

PDF66–75 and correction message144 inspected: handwritten page4 is absent by numbering error, not evidence of a missing PDF leaf. The first example stops before the final pivot placement; the lesson completes this required step. Source sketches are supplemented by bounded C++ code. Merge Sort has a worst case too; the meaningful contrast is Θ(n log n) versus Θ(n²) guarantees for these implementations. Knowing a frequent mark such as35 does not guarantee balanced partitions. Two-way duplicate handling can degenerate; source comparison conventions are stated explicitly.

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