الخوارزميات
مُقدَّم
12:39
الرياضيات المتقطعة GAC024
يُحسب عضو المجموعة المكرر مرة واحدة، وقد يتجاوز الحمل الثنائي عرضًا ثابتًا، وقد لا تكون أقصر مسار بأقل حواف هو الأقل وزناً. الرياضيات المتقطعة…
سرد باللغة الإنجليزية · ترجمة نصية بالإنجليزية و中文 يمكنك التبديل بينهما
في هذا الدرس
| English | المعنى |
|---|---|
| algorithm/ˈælɡərɪθəm/ | خوارزمية |
| flowchart/ˈfləʊtʃɑːt/ | مخطط انسيابي |
| pseudocode/ˈsuːdəʊkəʊd/ | الكود الوهمي |
| tracing/ˈtreɪsɪŋ/ | التتبع |
| binary search/ˈbaɪnəri sɜːtʃ/ | البحث الثنائي |
| linear search/ˈlɪnɪə sɜːtʃ/ | البحث الخطي |
| efficiency/ɪˈfɪʃənsi/ | الكفاءة |
Say which inputs the procedure must handle
- An algorithm 算法 describes unambiguous steps for a task. A procedure solving a stated finite task must terminate and give the correct result for every allowed input.
- A successful trace on one input shows that case, not a proof for all inputs. Boundary and empty-input cases can expose errors that a typical example misses.
ما الذي يجب توفره في سلسلة خطوات لتُعد خوارزمية؟ اختر كل ما ينطبق.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
الإجراء الذي يحل المهمة المحدودة finite stated يحتاج خطوات غير غامضة، ونتائج صحيحة وانتهاء على المدخلات المسموحة. الكود الوهمي والمخططات الانسيابية هي تمثيلات، وليست متطلبات لاستخدام لغة برمجة معينة.
Represent choices and updates clearly
- A flowchart 流程图 uses a decision diamond, process rectangle, input/output parallelogram and start/stop terminal, connected by directed flow arrows.
- Pseudocode 伪代码 describes the steps without requiring one implementation language. State assignment meaning, index origin, loop bounds and branch conditions before tracing.
![Binary search for 7 in [1, 3, 5, 7, 9, 11]: first the middle index 2 holds 5 < 7, so go right; second, the middle index 4 holds 9 > 7, so go left; third, index 3 holds 7, found after three comparisons under this convention](/learn-media/gac_mathematics/assets/0404-binary-search-steps.png?v=1794647931)
طابق كل شكل في المخطط الانسيابي مع معناه.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
استخدم مستطيلات العمليات، ومعالم القرار وبداية/نهاية كما هو معطى؛ الإدخال/الإخراج يُعرض عادةً بموازٍ. عيّن فروع قرار واتجاهات التدفق.
Record the actual variable values
- Tracing 追踪 follows the stated updates in order. A temporary variable may preserve a value that would otherwise be overwritten.
- Show low, high, middle and compared value for a binary search; show every changed variable for an arithmetic loop. Judge what the procedure does, not only its intended purpose.
A specified binary-search convention. Use zero-based inclusive bounds and floor of their average for the middle. Searching for 7 in [1,3,5,7,9,11] compares index 2/value 5, index 4/value 9, then index 3/value 7. The comparison count is three under this convention.
البحث الخطي مقابل البحث الثنائي
التقسيم للنصف يفوق الفحص واحداً تلو الآخر، وتزداد الفجوة مع طول القائمة.
باستخدام حدود شاملة قائمة على الصفر وقاعدة floor((low+high)/2)، كم عدد المقارنات التي تستخدم البحث الثنائي لإيجاد 7 في [1,3,5,7,9,11]؟
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
الفهارس الوسطى هي 2، 4، ثم 3، مع القيم 5، 9 و7. ثلاث مقارنات تحت الاتفاقية المحددة.
Compare work under its assumptions
- A linear search 线性查找 can stop early but may inspect all n items. A binary search repeatedly halves a sorted search range and needs consistent bound updates.
- Efficiency 效率 describes how required work scales with input size under a defined model. Sorting first has its own cost; an unsorted input cannot rely on binary search's ordering guarantee.
لقائمة مرتبة مسبقاً من مليون عنصر، كم عدد مقارنات القيمة الوسطى التي يمكن أن يحتاجها البحث الثنائي في أسوأ حالة تقريباً؟
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
كل مقارنة تُضعف نطاق البحث المتبقي؛ حوالي 20 مقارنة تكفي لمليون عنصر مرتب. هذا excludes أي تكلفة للتصنيف مسبقاً.
يعمل البحث الثنائي على قائمة غير مرتبة، لكن ببطء أكثر.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
بدون الترتيب المطلوب، استبعاد نصف يمكن أن يفوت عنصراً موجوداً. بعض الحالات قد تنجح بالصدفة، لكن الصحة غير مضمونة.
Check zero and the last allowed index. Sheet 4.4 examines a sum loop using i less than n, which misses the last term. Its Euclidean trace also explains termination: each positive divisor is replaced by a smaller nonnegative remainder until zero is reached.