Everything you need to explain AlgoLab
كل اللي محتاجه عشان تشرح AlgoLab
Read this once from top to bottom, then use the "Say it like this" boxes when you present. Every number on this page comes from the project's own code, docs and live API.
اقرا الصفحة دي مرة من الأول للآخر، وبعدين استخدم مربعات «قولها كده» وانت بتعرض. كل رقم هنا جاي من كود المشروع نفسه والدوكس والـ API.
"AlgoLab is a web lab for sorting algorithms. You pick up to ten algorithms and give them the same array. In the Race you watch every comparison, swap and write, step by step. In the Benchmark the server times them with repeated runs. In the Suite you see how their work grows as the input gets bigger or changes shape. It turns Big-O from a formula into something you can watch and measure."
«AlgoLab معمل على الويب لخوارزميات الترتيب. بتختار لحد عشر خوارزميات وبتديهم نفس المصفوفة. في الـ Race بتشوف كل مقارنة وكل تبديل وكل كتابة خطوة بخطوة. في الـ Benchmark السيرفر بيقيس وقتهم بتشغيل متكرر. وفي الـ Suite بتشوف الشغل بيكبر إزاي لما الـ input يكبر أو شكله يتغير. الفكرة إننا بنحوّل الـ Big-O من معادلة لحاجة تتشاف وتتقاس.»
The problem it solves
بيحل مشكلة إيه
On paper, Bubble Sort and Insertion Sort are both O(n²). In practice they do very different amounts of work on the same input, and a student rarely gets to see that. Big-O describes how cost grows; it does not show what the algorithm actually does. AlgoLab shows the exact operations and measures them on real data.
على الورق، Bubble Sort و Insertion Sort الاتنين O(n²). بس في الحقيقة بيعملوا كمية شغل مختلفة جدًا على نفس الـ input، والطالب نادرًا لما يشوف ده. الـ Big-O بيوصف التكلفة بتكبر إزاي، لكن مش بيوريك الخوارزمية بتعمل إيه بالظبط. AlgoLab بيوريك العمليات بالظبط وبيقيسها على داتا حقيقية.
The two-minute version
النسخة اللي في دقيقتين
- Frontend: React 19 + TypeScript, built with Vite. It never imports backend code; it talks to the API over HTTP with types generated from the API's OpenAPI schema.
- Backend: Python FastAPI, organised in layers (presentation, application, domain, algorithms, infrastructure). Heavy work runs in a separate worker process, one job at a time.
- Algorithms: ten sorting algorithms written so that every comparison, swap and write goes through one shared object. That object counts operations and, when asked, records a trace.
- Trust: every result is checked against Python's
sorted(), every algorithm gets its own copy of the input, and timings use warm-ups and repeated runs. - Shipping: Docker Compose locally, Azure Container Apps in the cloud, GitHub Actions for CI/CD, 558 backend tests.
- الفرونت إند: React 19 مع TypeScript، معمول بـ Vite. عمره ما بيستورد كود من الباك إند؛ بيكلم الـ API عن طريق HTTP، والـ types بتاعته متولّدة من الـ OpenAPI schema بتاعة الـ API.
- الباك إند: Python بـ FastAPI، متقسم طبقات (presentation و application و domain و algorithms و infrastructure). الشغل التقيل بيتعمل في process منفصلة (worker)، job واحدة في المرة.
- الخوارزميات: عشر خوارزميات ترتيب، مكتوبة بحيث إن كل مقارنة وكل تبديل وكل كتابة بتعدّي على object واحد مشترك. الـ object ده بيعد العمليات، ولو طلبنا منه بيسجّل trace.
- الثقة في النتايج: كل نتيجة بتتراجع على
sorted()بتاعة Python، وكل خوارزمية بتاخد نسخة لوحدها من الـ input، والتوقيت بيتقاس بعد warm-up وبتشغيل متكرر. - التشغيل والنشر: Docker Compose على الجهاز، Azure Container Apps على الكلاود، GitHub Actions للـ CI/CD، و 558 test للباك إند.
What is on the screen
إيه اللي على الشاشة
One page, three sections. They share the same algorithm selection: pick algorithms once and Race, Benchmark and Suite all use them.
صفحة واحدة فيها تلات أجزاء. التلاتة بيستخدموا نفس اختيار الخوارزميات: بتختار مرة واحدة، والـ Race والـ Benchmark والـ Suite كلهم بيشتغلوا على نفس الاختيار.
Race
Every algorithm sorts the same array at the same pace: one operation per step. The one with the fewest operations finishes first and gets 1st place.
كل خوارزمية بترتب نفس المصفوفة بنفس السرعة: عملية واحدة في كل خطوة. اللي محتاجة أقل عدد عمليات بتخلص الأول وتاخد المركز الأول.
Benchmark
The server times each algorithm on one dataset with warm-ups and repeated runs, then shows the median time, the range, and exact operation counts.
السيرفر بيقيس وقت كل خوارزمية على داتا واحدة، بعد warm-up وبتشغيل متكرر، وبيعرض الـ median والمدى (range) وعدد العمليات بالظبط.
Suite
Many cases at once (sizes × patterns), drawn as growth curves of comparisons, writes, swaps or time. This is where Big-O becomes visible.
حالات كتير مرة واحدة (أحجام × أنماط)، مرسومة كمنحنيات نمو للمقارنات أو الكتابات أو التبديلات أو الوقت. هنا الـ Big-O بيبان بعينك.
Race controls
أزرار الـ Race
- Dataset: size, min, max, pattern and seed. The same seed gives the same array every time.
- Playback: Play/Pause (Space), step back and forward (← →), Reset (R or Home), jump to end (End), a scrub bar, and speeds from 1 to 250 steps per second.
- Colours: compare, swap, write, sorted.
- Each lane shows live counts (comparisons, swaps, array writes) against the total, plus best/average/worst, space, stable and in-place.
- الداتا: الحجم والحد الأدنى والأقصى والنمط (pattern) والـ seed. نفس الـ seed بيطلّع نفس المصفوفة كل مرة.
- التشغيل: تشغيل/إيقاف (Space)، خطوة لورا وخطوة لقدام (← →)، Reset (R أو Home)، القفز للآخر (End)، شريط scrub، وسرعات من 1 لحد 250 خطوة في الثانية.
- الألوان: compare مقارنة، swap تبديل، write كتابة، sorted اترتب.
- كل lane بيعرض العدادات لحظة بلحظة (المقارنات والتبديلات والكتابات) قصاد الإجمالي، ومعاهم best و average و worst والـ space، وهل هي stable و in-place.
The tabs Searching, Graphs, Dynamic Programming, Backtracking in the top bar are placeholders for future work. Only Sorting works today. Say this clearly if asked.
التابات اللي فوق Searching و Graphs و Dynamic Programming و Backtracking مكان محجوز لشغل جاي. اللي شغال النهارده Sorting بس. قول ده بوضوح لو حد سأل.
Concepts to know
مفاهيم لازم تعرفها
Big-O, and best / average / worst case
الـ Big-O، وأحسن ومتوسط وأسوأ حالة
Big-O describes how the number of operations grows with the input size n. O(n) doubles when n doubles. O(n²) roughly quadruples. O(n log n) grows a little more than double. Best, average and worst case describe different inputs: Insertion Sort is O(n) on already-sorted data but O(n²) on reversed data.
الـ Big-O بيوصف عدد العمليات بيزيد إزاي مع حجم الـ input اللي بنسميه n. الـ O(n) بيتضاعف لما n تتضاعف. الـ O(n²) بيتضرب في 4 تقريبًا. الـ O(n log n) بيزيد أكتر من الضعف بشوية. وأحسن ومتوسط وأسوأ حالة معناهم أنواع input مختلفة: Insertion Sort بيبقى O(n) على داتا مترتبة أصلًا، لكنه O(n²) على داتا معكوسة.
Space, stable, in place, comparison-based
الـ Space والـ Stable والـ In place والـ Comparison-based
- Auxiliary space: extra memory beyond the array. O(1) means a few variables only.
- Stable: equal values keep their original order. Example: two students with grade 90; a stable sort keeps whoever came first still first. Matters when you sort records by one field after another.
- In place: sorts inside the same array instead of building a new one.
- Comparison-based: decides order only by comparing two values. Any comparison sort needs at least about n log n comparisons in the worst case. Frequency Sort is not comparison-based, which is how it can be O(n + k).
- الـ Auxiliary space: الذاكرة الزيادة غير المصفوفة نفسها. O(1) معناها شوية متغيرات بس.
- Stable (مستقرة): القيم المتساوية بتفضل بنفس ترتيبها الأصلي. مثال: طالبين جابوا 90؛ الترتيب المستقر بيخلّي اللي كان الأول يفضل الأول. ده مهم لما ترتب records بحقل وبعدين بحقل تاني.
- In place (في نفس المكان): بترتب جوه نفس المصفوفة من غير ما تبني واحدة جديدة.
- Comparison-based: بتحدد الترتيب بمقارنة قيمتين ببعض بس. أي خوارزمية بالمقارنة محتاجة على الأقل حوالي n log n مقارنة في أسوأ حالة. Frequency Sort مش بالمقارنة، وعشان كده تقدر تبقى O(n + k).
The four things AlgoLab counts
الأربع حاجات اللي AlgoLab بيعدّها
Comparison: two input values are compared. Loop and index checks are not counted.
Comparison (مقارنة): قيمتين من الـ input بيتقارنوا ببعض. شروط اللوب والـ index مش بتتحسب.
Swap: two different positions exchange values. One swap counts as two array writes.
Swap (تبديل): مكانين مختلفين بيبدّلوا قيمهم. التبديل الواحد بيتحسب كتابتين في المصفوفة.
Array write: a value is assigned into the array, for example when Insertion Sort shifts values.
Array write (كتابة): قيمة بتتحط في مكان في المصفوفة، زي لما Insertion Sort بيزق القيم.
Auxiliary write: a write to extra storage, like Frequency Sort's count table or Quick Sort's stack.
Auxiliary write (كتابة مساعدة): كتابة في مكان تخزين زيادة، زي جدول العدّ في Frequency Sort أو الـ stack في Quick Sort.
What a trace is
يعني إيه trace
A trace is the complete, ordered list of operations an algorithm performed. Each event has a sequence number, a kind (compare, swap or write), the indices, and the values. Replaying the swap and write events on the original array must rebuild the sorted result exactly. The Race is just a replay of these traces.
الـ trace هو الليستة الكاملة المترتبة لكل العمليات اللي الخوارزمية عملتها. كل event فيه رقم تسلسل، ونوع (compare أو swap أو write)، والـ indices، والقيم. لو أعدنا تنفيذ أحداث الـ swap والـ write على المصفوفة الأصلية، لازم يطلع الناتج المترتب بالظبط. الـ Race ما هوش غير replay للـ traces دي.
| sequence | kind | indices | values | meaning | المعنى |
|---|---|---|---|---|---|
| 0 | compare | [0, 1] | [5, 2] | 5 > 2, out of order5 أكبر من 2، الترتيب غلط | |
| 1 | swap | [0, 1] | [2, 5] | values after the swapالقيم بعد التبديل | |
| 2 | compare | [1, 2] | [5, 4] | 5 > 4, swap again5 أكبر من 4، هنبدّل تاني |
Real output from POST /api/v1/sort for Bubble Sort on [5, 2, 4, 1]: 11 events, 6 comparisons, 5 swaps, 10 array writes.
ده ناتج حقيقي من POST /api/v1/sort لـ Bubble Sort على [5, 2, 4, 1]: 11 event، و 6 مقارنات، و 5 تبديلات، و 10 كتابات.
Watch them sort
شوف الترتيب بعينك
This small player runs the same logic as the project's Python implementations, on ten values. Pick an algorithm, then press Play or step through it. Read the algorithm's card in the next section while it runs.
المشغّل الصغير ده بيشغّل نفس منطق الكود اللي في المشروع بالـ Python، على عشر قيم. اختار خوارزمية واضغط Play أو امشي خطوة خطوة. واقرا الكارت بتاعها في الجزء اللي بعده وهي شغالة.
Try Insertion Sort: you will see writes (shifts) and zero swaps. Try Frequency Sort: comparisons only to find the min and max, then pure writes.
جرّب Insertion Sort: هتلاقي كتابات (زق للقيم) وصفر تبديلات. وجرّب Frequency Sort: مقارنات بس عشان يلاقي أصغر وأكبر قيمة، وبعد كده كتابات بس.
The ten algorithms
الخوارزميات العشرة
Grouped by how their work grows. Open a card for the steps, the detail of our implementation, and what to say about it.
متقسمين حسب الشغل بيكبر إزاي. افتح أي كارت عشان تشوف الخطوات، وتفاصيل الـ implementation بتاعتنا، وتقول إيه عنها.
| Algorithm | الخوارزمية | Best | Average | Worst | Space | Stable | In place |
|---|---|---|---|---|---|---|---|
| Selection Sort | O(n²) | O(n²) | O(n²) | O(1) | no | yes | |
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) | yes | yes | |
| Odd-Even Sort | O(n) | O(n²) | O(n²) | O(1) | yes | yes | |
| Cocktail Sort | O(n) | O(n²) | O(n²) | O(1) | yes | yes | |
| Insertion Sort | O(n) | O(n²) | O(n²) | O(1) | yes | yes | |
| Binary Insertion Sort | O(n) | O(n²) | O(n²) | O(1) | yes | yes | |
| Shell Sort | O(n log n) | unknown* | O(n²) | O(1) | no | yes | |
| Heap Sort | O(n)** | O(n log n) | O(n log n) | O(1) | no | yes | |
| Quick Sort | O(n)*** | O(n log n) | O(n²) | O(log n) | no | yes | |
| Frequency Sort | O(n + k) | O(n + k) | O(n + k) | O(k) | no | no |
* No average bound is claimed for the halving-gap sequence. ** Only with many equal values; with distinct values the best case is O(n log n). *** When all values are equal, thanks to three-way partitioning. k = max − min + 1.
* مفيش حد متوسط معروف لتسلسل الـ gaps اللي بيتقسم على 2. ** بس لما يبقى فيه قيم كتير متساوية؛ لو القيم كلها مختلفة أحسن حالة O(n log n). *** لما كل القيم تبقى متساوية، بسبب التقسيم لتلات أجزاء. k = أكبر قيمة − أصغر قيمة + 1.
Simple quadratic sorts · O(n²)
خوارزميات بسيطة تربيعية · O(n²)
Selection Sort
Find the smallest remaining value and put it next.دوّر على أصغر قيمة فاضلة وحطها في مكانها.
How it works
بتشتغل إزاي
- Scan the unsorted part and remember the position of the smallest value.
- Swap it into the first unsorted position.
- The sorted part grows by one; repeat.
- امشي على الجزء اللي لسه مش مترتب واحفظ مكان أصغر قيمة.
- بدّلها مع أول مكان في الجزء اللي مش مترتب.
- الجزء المترتب يكبر بواحد، وكرر.
In our code
في الكود بتاعنا
Exactly one swap per pass, so at most n − 1 swaps: the fewest swaps of any algorithm here. But it always makes about n²/2 comparisons, even on sorted input. The long-distance swap is what breaks stability.
تبديل واحد بالظبط في كل لفة، يعني أقصى حاجة n − 1 تبديل: أقل عدد تبديلات بين كل الخوارزميات هنا. بس دايمًا بتعمل حوالي n²/2 مقارنة، حتى لو الداتا مترتبة. والتبديل لمسافة بعيدة هو اللي بيبوّظ الـ stability.
Say: "Few writes, many comparisons. Useful when writing is expensive."
قول: «كتابات قليلة ومقارنات كتير. مفيدة لما الكتابة تبقى مكلفة.»
Bubble Sort
Swap neighbours that are out of order; big values bubble to the end.بدّل الجيران اللي ترتيبهم غلط؛ القيم الكبيرة بتطلع للآخر زي الفقاعة.
How it works
بتشتغل إزاي
- Walk left to right comparing each pair of neighbours.
- If the left one is bigger, swap them.
- After one pass, the largest value is at the end. Repeat on the rest.
- امشي من الشمال لليمين وقارن كل جارين.
- لو اللي على الشمال أكبر، بدّلهم.
- بعد لفة واحدة، أكبر قيمة بتوصل للآخر. كرر على الباقي.
In our code
في الكود بتاعنا
We remember the position of the last swap. Everything after it is already sorted, so the next pass stops there. A pass with no swaps ends the sort, which is why sorted input costs only n − 1 comparisons (best case O(n)).
بنفتكر مكان آخر تبديل. كل اللي بعده مترتب أصلًا، فاللفة اللي بعدها بتقف عنده. ولو لفة عدّت من غير أي تبديل، الترتيب بيخلص. عشان كده الداتا المترتبة بتاخد n − 1 مقارنة بس (أحسن حالة O(n)).
Say: "The classic teaching example. In our Race on 24 values it took 430 steps, the slowest of the four."
قول: «ده المثال الكلاسيكي في التدريس. في الـ Race بتاعنا على 24 قيمة خد 430 خطوة، وكان الأبطأ في الأربعة.»
Odd-Even Sort
Bubble Sort in two alternating phases: even pairs, then odd pairs.Bubble Sort على مرحلتين بالتبادل: الأزواج الزوجية، وبعدين الفردية.
How it works
بتشتغل إزاي
- Even phase: compare pairs (0,1), (2,3), (4,5)… and swap if needed.
- Odd phase: compare pairs (1,2), (3,4), (5,6)…
- Repeat both phases until a full cycle makes no swap.
- المرحلة الزوجية: قارن الأزواج (0,1) و (2,3) و (4,5)… وبدّل لو محتاج.
- المرحلة الفردية: قارن الأزواج (1,2) و (3,4) و (5,6)…
- كرر المرحلتين لحد ما دورة كاملة تعدّي من غير تبديل.
The pairs inside one phase never overlap, so on parallel hardware they could all run at once. In AlgoLab both phases run one after the other.
الأزواج جوه المرحلة الواحدة عمرهم ما بيتداخلوا، فعلى hardware متوازي ممكن يتنفذوا كلهم في نفس اللحظة. في AlgoLab المرحلتين بيتنفذوا ورا بعض.
Say: "Designed for parallel machines; on one core it behaves like Bubble Sort."
قول: «معمولة للأجهزة المتوازية؛ على core واحد بتتصرف زي Bubble Sort.»
Cocktail Sort
Bubble Sort that sweeps both ways: right for the max, left for the min.Bubble Sort بيلف في الاتجاهين: يمين عشان أكبر قيمة، وشمال عشان أصغر قيمة.
How it works
بتشتغل إزاي
- Sweep right, moving the largest value to the end.
- Sweep left, moving the smallest value to the start.
- Shrink both ends; stop as soon as a sweep makes no swap.
- لف يمين، ووصّل أكبر قيمة للآخر.
- لف شمال، ووصّل أصغر قيمة للأول.
- صغّر الطرفين، واقف أول ما لفة تعدّي من غير تبديل.
It fixes Bubble Sort's "turtles": small values stuck near the end that move only one step per pass. Going back left carries them home quickly.
بتحل مشكلة الـ «turtles» في Bubble Sort: قيم صغيرة محبوسة قرب الآخر وبتتحرك خطوة واحدة بس في كل لفة. اللفة الراجعة شمال بترجّعها لمكانها بسرعة.
Insertion Sort
Take the next value and slide it back into the sorted part, like sorting cards in your hand.خد القيمة اللي بعدها وزقّها لورا في الجزء المترتب، زي ما بترتب الكوتشينة في إيدك.
How it works
بتشتغل إزاي
- Hold the next value as the key.
- Shift every bigger value in the sorted part one step right.
- Write the key into the gap.
- امسك القيمة اللي بعدها وسمّيها key.
- زق كل قيمة أكبر منها في الجزء المترتب خطوة لليمين.
- اكتب الـ key في المكان اللي فضي.
In our code
في الكود بتاعنا
It uses shifts (writes), not swaps, so the Race shows 0 swaps for it. It shifts only strictly bigger values, which keeps equal values in order (stable). A value already in place costs one comparison and no write.
بتستخدم زق (كتابات) مش تبديلات، وعشان كده الـ Race بيوريها صفر تبديل. وبتزق القيم الأكبر بس، فالقيم المتساوية بتفضل بنفس ترتيبها (stable). والقيمة اللي في مكانها أصلًا بتكلّف مقارنة واحدة ومن غير كتابة.
Say: "On sorted input it needs only n − 1 comparisons. At 500 sorted values it made 499 comparisons, while Quick Sort made 7,649."
قول: «على داتا مترتبة محتاجة n − 1 مقارنة بس. على 500 قيمة مترتبة عملت 499 مقارنة، و Quick Sort عمل 7,649.»
Binary Insertion Sort
Insertion Sort that finds the insert position with binary search.Insertion Sort بيدوّر على مكان الإدخال بالـ binary search.
Binary search cuts comparisons to O(n log n) overall, but the values still have to be shifted, so writes stay O(n²). We search for the position after equal values (an upper bound) to stay stable. If the key is already ≥ its left neighbour, we skip the search entirely: that fast path makes the best case O(n).
الـ binary search بيقلل المقارنات لـ O(n log n) في المجمل، بس القيم لسه لازم تتزق، فالكتابات بتفضل O(n²). بندوّر على المكان اللي بعد القيم المتساوية (upper bound) عشان تفضل stable. ولو الـ key أكبر من أو يساوي الجار اللي على شماله، بنتخطى البحث خالص: الطريق السريع ده هو اللي بيخلّي أحسن حالة O(n).
Say: "A good example that comparisons and writes are different costs: fewer comparisons, same number of writes."
قول: «مثال حلو إن المقارنات والكتابات تكلفتين مختلفتين: مقارنات أقل، ونفس عدد الكتابات.»
Faster than quadratic
أسرع من التربيعي
Shell Sort
Insertion Sort on far-apart elements first, then closer, then neighbours.Insertion Sort على عناصر بعيدة عن بعض الأول، وبعدين أقرب، وبعدين الجيران.
We use the original gap sequence: n/2, n/4, …, 1. With a big gap, values jump long distances at once. The last pass (gap 1) is a normal Insertion Sort on data that is now almost sorted, which is Insertion Sort's best case. Long jumps can move equal values past each other, so it is not stable. The API honestly reports the average case as "unknown" for this gap sequence.
بنستخدم تسلسل الـ gaps الأصلي: n/2 وبعدين n/4 لحد 1. لما الـ gap يبقى كبير، القيم بتنط مسافات بعيدة مرة واحدة. آخر لفة (gap = 1) بتبقى Insertion Sort عادي على داتا بقت شبه مترتبة، ودي أحسن حالة لـ Insertion Sort. النطّ لمسافات بعيدة ممكن يعدّي قيم متساوية على بعض، فهي مش stable. والـ API بيقول بأمانة إن الحالة المتوسطة «unknown» للتسلسل ده.
Heap Sort
Build a max-heap, then repeatedly move the maximum to the end.ابني max-heap، وبعدين انقل أكبر قيمة للآخر مرة ورا مرة.
How it works
بتشتغل إزاي
- View the array as a binary tree: the children of position i are 2i + 1 and 2i + 2.
- Build a max-heap bottom-up: every parent is ≥ its children, so the maximum is at position 0.
- Swap position 0 with the last element, shrink the heap by one, and sift the new root down. Repeat.
- اعتبر المصفوفة شجرة binary: أولاد المكان i هما 2i + 1 و 2i + 2.
- ابني max-heap من تحت لفوق: كل أب أكبر من أو يساوي أولاده، فأكبر قيمة بتبقى في المكان 0.
- بدّل المكان 0 مع آخر عنصر، صغّر الـ heap بواحد، ونزّل الـ root الجديد لمكانه (sift down). كرر.
Its worst case is still O(n log n), unlike Quick Sort, and it needs no extra memory. Our sift-down stops early when the parent is already ≥ the bigger child.
أسوأ حالة ليها لسه O(n log n)، عكس Quick Sort، ومش محتاجة ذاكرة زيادة. والـ sift-down عندنا بيقف بدري لو الأب أصلًا أكبر من أو يساوي الابن الأكبر.
Say: "Guaranteed n log n with constant memory; the price is losing stability."
قول: «n log n مضمونة وبذاكرة ثابتة؛ والتمن إنها مش stable.»
Quick Sort
Pick a pivot, split into smaller / equal / larger, and repeat on each side.اختار pivot، قسّم لأصغر ومساوي وأكبر، وكرر على كل ناحية.
In our code (four design choices)
في الكود بتاعنا (أربع قرارات تصميم)
- Median-of-three pivot: the middle value of the first, middle and last elements. This avoids the classic O(n²) on already-sorted input.
- Three-way partition: values become < pivot, = pivot and > pivot. Many duplicates are handled fast; all-equal input is O(n).
- Iterative, with an explicit stack instead of recursion.
- Smaller side first: the larger side waits on the stack, so the stack never grows past O(log n).
- Pivot بـ median-of-three: القيمة اللي في النص بين أول عنصر واللي في النص وآخر عنصر. ده بيمنع الـ O(n²) الشهيرة على داتا مترتبة أصلًا.
- تقسيم لتلات أجزاء: القيم بتبقى أصغر من الـ pivot، وتساويه، وأكبر منه. القيم المكررة الكتير بتتعامل بسرعة، والداتا اللي كلها متساوية بتبقى O(n).
- Iterative بـ stack صريح بدل الـ recursion.
- الناحية الأصغر الأول: الناحية الأكبر بتستنى على الـ stack، فالـ stack عمره ما يكبر عن O(log n).
The worst case is still O(n²) for adversarial input, so the API's admission budget treats Quick Sort as quadratic to stay safe.
أسوأ حالة لسه O(n²) لو حد قاصد يديها input وحش، وعشان كده ميزانية الشغل في الـ API بتعامل Quick Sort كأنها تربيعية عشان نبقى في الأمان.
Say: "Fastest comparison sort in our tests: 0.74 ms for 500 values, about 20× faster than Bubble Sort."
قول: «أسرع خوارزمية بالمقارنة في الاختبارات بتاعتنا: 0.74 ms لـ 500 قيمة، أسرع من Bubble Sort بحوالي 20 مرة.»
No comparisons between values · linear
من غير مقارنة بين القيم · خطية
Frequency Sort (Counting Sort)
Count how many times each value appears, then write them back in order.عدّ كل قيمة اتكررت كام مرة، وبعدين اكتبهم تاني بالترتيب.
- Find the smallest and largest value (the only comparisons).
- Make a count table of size k = max − min + 1 and count every value.
- Walk the table from the smallest value and write each value back as many times as it was counted.
- لاقي أصغر وأكبر قيمة (دي المقارنات الوحيدة).
- اعمل جدول عدّ حجمه k = أكبر − أصغر + 1 وعدّ كل قيمة.
- امشي على الجدول من أصغر قيمة، واكتب كل قيمة تاني بعدد المرات اللي اتعدّت.
The name can mislead: it does not order values by how often they appear; it is a counting sort in ascending order. It rebuilds integers instead of moving records, so it is not considered stable, and it needs the extra table, so it is not in place. The value range is capped at 100,000 because the table grows with k.
الاسم ممكن يلخبط: هي مش بترتب القيم حسب عدد مرات تكرارها؛ هي counting sort تصاعدي. بتعيد بناء الأرقام بدل ما تحرك records، فمش بنعتبرها stable، ومحتاجة الجدول الزيادة، فهي مش in place. ومدى القيم أقصاه 100,000 لأن الجدول بيكبر مع k.
Say: "It beats the n log n limit because it never compares two values to decide order. It was the fastest in our benchmark: 0.66 ms for 500 values."
قول: «بتكسر حد الـ n log n لأنها عمرها ما بتقارن قيمتين عشان تقرر الترتيب. وكانت الأسرع في الـ benchmark بتاعنا: 0.66 ms لـ 500 قيمة.»
How it works inside
بيشتغل إزاي من جوه
openapi-fetch, generated types
Replay engine
proxies /api and /health
The layers, in plain words
الطبقات بكلام بسيط
- Presentation receives HTTP requests, validates them with schemas, and turns errors into one JSON shape:
{"error": {"code", "message"}}. - Application holds the use cases: make a dataset, sort, benchmark, run a suite. It checks the limits before any work starts.
- Domain holds the rules and contracts, with no framework imports.
SortContextlives here. - Algorithms are pure functions registered by a stable id like
quick_sort. They never read clocks, make data, or touch HTTP. - Infrastructure runs the work in a separate process and provides the clock.
- Presentation بتستقبل طلبات الـ HTTP، وتتأكد منها بالـ schemas، وتحوّل أي error لشكل JSON واحد:
{"error": {"code", "message"}}. - Application فيها الـ use cases: اعمل داتا، رتّب، اعمل benchmark، شغّل suite. وبتراجع الحدود قبل ما أي شغل يبدأ.
- Domain فيها القواعد والعقود (contracts)، ومن غير أي framework. الـ
SortContextموجود هنا. - Algorithms دوال صافية (pure) متسجلة بـ id ثابت زي
quick_sort. عمرها ما بتقرا ساعة ولا بتعمل داتا ولا بتلمس HTTP. - Infrastructure بتشغّل الشغل في process منفصلة وبتوفّر الساعة (clock).
Why layers? Dependencies point inward, so the core rules do not depend on FastAPI. You can test algorithms without a server, and add a new algorithm without touching the HTTP code.
ليه طبقات؟ الاعتماديات بتشاور لجوه، فالقواعد الأساسية مش معتمدة على FastAPI. تقدر تعمل test للخوارزميات من غير سيرفر، وتضيف خوارزمية جديدة من غير ما تلمس كود الـ HTTP.
SortContext: the one object every algorithm uses
SortContext: الـ object الوحيد اللي كل خوارزمية بتستخدمه
Algorithms never write values[i], values[j] = … directly. They call context.compare(), context.swap(), context.write() and context.auxiliary_write(). The context does the real operation and, depending on switches, counts it and records it as an event. The same algorithm code runs in three modes: counting on (metrics), tracing on (Race), or both off (timing).
الخوارزميات عمرها ما بتكتب values[i], values[j] = … بنفسها. بتنادي context.compare() و context.swap() و context.write() و context.auxiliary_write(). الـ context بيعمل العملية الحقيقية، وحسب الإعدادات بيعدّها وبيسجّلها كـ event. نفس كود الخوارزمية بيشتغل بتلات طرق: العدّ شغال (للأرقام)، أو التسجيل شغال (للـ Race)، أو الاتنين مقفولين (للتوقيت).
What happens when you press Start race
إيه اللي بيحصل لما تدوس Start race
- The browser sends
POST /api/v1/sortwith the array, the algorithm ids andtrace: true. - FastAPI validates the body (types, sizes, at most 128 values for a trace) and hands the job to the worker queue. If 4 requests are already waiting it answers 503
execution_busy. - The worker process gives each algorithm its own copy of the array and runs it with tracing on.
- Each result is checked against Python's
sorted(). A wrong answer stops the experiment with an error. - The response returns, for each algorithm, the output, the metrics and the full list of events.
- The browser builds a Replay per algorithm. A timer moves one shared cursor forward at the chosen speed, and each lane draws the array at that step. The shortest trace finishes first.
- المتصفح بيبعت
POST /api/v1/sortفيه المصفوفة و ids الخوارزميات وtrace: true. - FastAPI بيتأكد من الطلب (الأنواع، والأحجام، وإن الـ trace مش أكتر من 128 قيمة) وبيدّي الشغل لطابور الـ worker. لو فيه 4 طلبات مستنية أصلًا، بيرد بـ 503
execution_busy. - الـ worker process بيدّي كل خوارزمية نسخة لوحدها من المصفوفة وبيشغّلها والتسجيل شغال.
- كل نتيجة بتتراجع على
sorted()بتاعة Python. لو فيه إجابة غلط، التجربة بتقف بـ error. - الرد بيرجع لكل خوارزمية: الناتج، والأرقام، والليستة الكاملة للـ events.
- المتصفح بيبني Replay لكل خوارزمية. فيه timer بيحرّك cursor واحد مشترك لقدام بالسرعة اللي اخترتها، وكل lane بترسم المصفوفة عند الخطوة دي. الـ trace الأقصر بيخلص الأول.
The replay engine (frontend)
محرك الـ replay (في الفرونت)
Stepping backward or dragging the scrub bar needs no new request. The engine saves a snapshot of the bars every 256 events (a checkpoint). To show step 1,000 it starts from the checkpoint at 768 and replays only the events after it. Bars keep a stable id, so a value can animate to its new position when it moves.
الرجوع خطوة لورا أو سحب شريط الـ scrub مش محتاج request جديد. المحرك بيحفظ صورة من الأعمدة كل 256 event (بنسميها checkpoint). عشان يعرض الخطوة 1,000، بيبدأ من الـ checkpoint اللي عند 768 ويعيد الـ events اللي بعدها بس. وكل عمود ليه id ثابت، فالقيمة تقدر تتحرك بأنيميشن لمكانها الجديد لما تتنقل.
Why a separate worker process?
ليه process منفصلة للـ worker؟
Sorting is CPU work. Running it in the web process would block other requests, and two benchmarks running together would slow each other down and spoil the timings. One worker process runs one experiment at a time; the web process stays responsive; at most 4 requests can be in flight. The process is started with spawn, so it builds its own registry and clock and shares nothing by accident.
الترتيب شغل على الـ CPU. لو اتشغّل في process الويب، هيعطّل باقي الطلبات، ولو اتنين benchmark اشتغلوا مع بعض، هيبطّأوا بعض ويبوّظوا التوقيت. فيه worker process واحدة بتشغّل تجربة واحدة في المرة؛ و process الويب بتفضل سريعة؛ وأقصى عدد طلبات شغالة أو مستنية 4. الـ process بتبدأ بـ spawn، فبتبني الـ registry والـ clock بتوعها لوحدها ومش بتشارك حاجة بالغلط.
Tech stack
التقنيات المستخدمة
| Part | الجزء | Tools | الأدوات |
|---|---|---|---|
| Frontendالفرونت | React 19, TypeScript, Vite, Vitest, oxlint, openapi-typescript, openapi-fetch | ||
| Backendالباك | Python 3.12+, FastAPI, Uvicorn, pytest (558 tests), mypy strict, Ruff | ||
| Runningالتشغيل | Docker, Docker Compose (api + web via Nginx) | ||
| Cloudالكلاود | Azure Container Apps (public web, internal API), Bicep, GitHub Actions CI/CD |
Fair measurement
القياس العادل
A benchmark runs three kinds of pass
الـ benchmark فيه تلات أنواع تشغيل
- Instrument: one pass with counting on and tracing off, to get exact operation counts.
- Warm up: 0 to 3 untimed passes, so caches and the interpreter settle.
- Measure: 1 to 15 timed passes with all counting off. Report the median, min, max and spread.
- Instrument: تشغيلة واحدة والعدّ شغال والتسجيل مقفول، عشان ناخد عدد العمليات بالظبط.
- Warm up: من 0 لـ 3 تشغيلات من غير توقيت، عشان الـ cache والـ interpreter يستقروا.
- Measure: من 1 لـ 15 تشغيلة متوقتة والعدّ كله مقفول. وبنطلّع الـ median والأقل والأكبر والفرق بينهم.
Rules that keep it fair
قواعد بتخلّي القياس عادل
- Every algorithm gets a fresh copy of the same input on every pass.
- Only the call to the algorithm is inside the timer: no copying, checking or JSON.
- The order of algorithms is shuffled each round, with a seed, so none always runs first.
- Algorithms run one after the other, never at the same time.
- Median is used for ranking because one slow outlier run does not move it.
- A noise warning appears when the fastest algorithm's range overlaps another's: the ranking might flip on another run. In the app it says "Too close to call".
- كل خوارزمية بتاخد نسخة جديدة من نفس الـ input في كل تشغيلة.
- جوه التوقيت فيه بس نداء الخوارزمية: مفيش نسخ ولا مراجعة ولا JSON.
- ترتيب الخوارزميات بيتلخبط في كل جولة، بـ seed، عشان مفيش واحدة تشتغل الأولى دايمًا.
- الخوارزميات بتشتغل ورا بعض، عمرها ما بتشتغل في نفس الوقت.
- بنرتب بالـ median لأن تشغيلة واحدة بطيئة بالصدفة مش بتأثر عليه.
- بيظهر noise warning لما مدى الوقت بتاع أسرع خوارزمية يتداخل مع مدى واحدة تانية: يعني الترتيب ممكن يتقلب في تشغيلة تانية. في الأبلكيشن بيقول «Too close to call».
"Times describe these Python implementations on this server. Operation counts are exact and the same on every machine. Animation speed in the Race is not runtime."
«التوقيت بيوصف الـ implementations دي بالـ Python على السيرفر ده بس. لكن عدد العمليات دقيق وثابت على أي جهاز. وسرعة الأنيميشن في الـ Race مش هي وقت التنفيذ.»
Datasets and seeds
الداتا والـ seeds
Five patterns: random, sorted, reversed, nearly sorted (sorted, then n/20 random swaps), few unique (at most five distinct values). The API always returns the seed it used; the same seed and settings rebuild the same data, so every experiment can be repeated.
فيه خمس أنماط: random عشوائي، وsorted مترتب، وreversed معكوس، وnearly sorted شبه مترتب (مترتب وبعدين n/20 تبديل عشوائي)، وfew unique قيم قليلة مختلفة (أقصاها خمس قيم). الـ API دايمًا بيرجّع الـ seed اللي استخدمه؛ ونفس الـ seed مع نفس الإعدادات بيطلّع نفس الداتا، فأي تجربة ممكن تتكرر.
Limits (guardrails)
الحدود (Guardrails)
| Limit | الحد | Value | القيمة |
|---|---|---|---|
| Values in a traceعدد القيم في الـ trace | 128 · 20,000 events | ||
| Algorithms per requestخوارزميات في الطلب الواحد | 1–10 | ||
| Array sizeحجم المصفوفة | ≤ 1,000 (simple sorts) · ≤ 10,000 (Heap, Quick, Frequency) | ||
| Repeats / warm-upsالتكرارات / الـ warm-ups | 1–15 / 0–3 | ||
| Suite casesحالات الـ Suite | ≤ 12 | ||
| Work budgetميزانية الشغل | 50,000,000 units | ||
| Requests in flightالطلبات الشغالة | 4, then 503 | ||
| Request bodyحجم الطلب | 1,000,000 bytes |
Numbers to quote
أرقام تقولها
All from the live API on the dev branch. Counts are exact; times are from one machine.
كلها من الـ API شغال على برانش dev. عدد العمليات دقيق؛ والأوقات من جهاز واحد.
Race steps, Quick vs Bubble Sort, same 24 values (seed 42).
خطوات الـ Race بين Quick و Bubble Sort، على نفس الـ 24 قيمة (seed 42).
Quick Sort 0.74 ms vs Bubble Sort 14.6 ms, 500 random values.
Quick Sort خد 0.74 ms و Bubble Sort خد 14.6 ms، على 500 قيمة عشوائية.
Fewer comparisons for Quick (9,910) than Bubble (497,458) at n = 1,000.
مقارنات Quick (9,910) أقل من Bubble (497,458) بـ 50 مرة عند n = 1,000.
On sorted input, Insertion (499) beats Quick (7,649) in comparisons.
على داتا مترتبة، Insertion (499) بتكسب Quick (7,649) في المقارنات.
On reversed input it flips: Insertion 124,730 vs Quick 6,215.
على داتا معكوسة الآية بتتقلب: Insertion عملت 124,730 و Quick عملت 6,215.
Doubling n from 500 to 1,000: Bubble ×4.0, Insertion ×4.1, Heap ×2.3, Quick ×2.0.
لما n تتضاعف من 500 لـ 1,000: Bubble ×4.0، و Insertion ×4.1، و Heap ×2.3، و Quick ×2.0.
| Median time, 500 random values | الـ median لـ 500 قيمة عشوائية | ms |
|---|---|---|
| Frequency Sort | 0.66 | |
| Quick Sort | 0.74 | |
| Shell Sort | 0.75 | |
| Heap Sort | 0.93 | |
| Binary Insertion Sort | 3.50 | |
| Insertion Sort | 8.26 | |
| Selection Sort | 8.52 | |
| Cocktail Sort | 13.13 | |
| Bubble Sort | 14.60 | |
| Odd-Even Sort | 14.66 |
Notice Binary Insertion (3.50) beats Insertion (8.26): same writes, far fewer comparisons, and comparisons are expensive in Python.
خد بالك إن Binary Insertion (3.50) أسرع من Insertion (8.26): نفس الكتابات، بس مقارنات أقل بكتير، والمقارنة في Python مكلفة.
Demo script
سيناريو العرض
About five minutes. Do these in order; the bold line is what to say.
حوالي خمس دقايق. اعملهم بالترتيب؛ والسطر اللي بالـ bold هو اللي تقوله.
- Open the page. "One array, ten possible algorithms, three ways to compare them."
- In Race, keep Bubble, Insertion and Quick, then add Heap Sort. Press Start race, set 25 steps/s, Play. "Each step is one real operation recorded by the backend."
- Pause mid-race and point at a pink pair. "Pink is a swap. Insertion Sort never swaps; it shifts with blue writes."
- Let it finish. "Quick Sort wins with 167 steps; Bubble needs 430." Drag the scrub bar back. "Scrubbing happens in the browser, no new request."
- Benchmark, Run. "Real timings: median of repeated runs after a warm-up." Hover a bar for the samples, then switch to Comparisons. "Counts are exact; times vary."
- Suite: tick Sorted and Reversed, Run. Hover the charts. "On sorted data Insertion Sort is the best; on reversed data it is the worst. That is best case versus worst case."
- Switch to dark mode, then close. "Everything is reproducible with a seed, and new algorithm families plug into the same model."
- افتح الصفحة. «مصفوفة واحدة، وعشر خوارزميات ممكن نختار منهم، وتلات طرق نقارنهم بيها.»
- في الـ Race، سيب Bubble و Insertion و Quick وضيف Heap Sort. دوس Start race، وخلّي السرعة 25 خطوة في الثانية، ودوس Play. «كل خطوة عملية حقيقية الباك إند سجّلها.»
- وقّف في نص السباق وشاور على عمودين بمبي. «البمبي ده swap. Insertion Sort عمره ما بيبدّل؛ بيزق بكتابات زرقا.»
- سيبه يخلص. «Quick Sort كسب بـ 167 خطوة؛ و Bubble محتاج 430.» اسحب شريط الـ scrub لورا. «الرجوع بيحصل في المتصفح، من غير request جديد.»
- في الـ Benchmark دوس Run. «أوقات حقيقية: median لتشغيلات متكررة بعد warm-up.» قف بالماوس على عمود عشان تشوف العينات، وبعدين بدّل لـ Comparisons. «عدد العمليات دقيق؛ لكن الوقت بيتغير.»
- في الـ Suite علّم على Sorted و Reversed ودوس Run. قف بالماوس على الشارتس. «على داتا مترتبة Insertion Sort هي الأحسن؛ وعلى داتا معكوسة هي الأوحش. ده الفرق بين أحسن حالة وأسوأ حالة.»
- بدّل لـ dark mode، واختم. «كل حاجة تتكرر بنفس الـ seed، وأي عيلة خوارزميات جديدة هتتركب على نفس الفكرة.»
Likely questions
أسئلة متوقعة
Why is Quick Sort fast if its worst case is O(n²)?ليه Quick Sort سريعة مع إن أسوأ حالة ليها O(n²)؟
The worst case needs very bad pivots every time. Median-of-three makes that unlikely on normal data, including sorted and reversed input, and three-way partitioning handles duplicates. On average it is O(n log n) with small constants and cache-friendly access.
أسوأ حالة محتاجة pivot وحش جدًا في كل مرة. الـ median-of-three بيخلّي ده صعب يحصل على داتا عادية، حتى المترتبة والمعكوسة، والتقسيم لتلات أجزاء بيتعامل مع القيم المكررة. في المتوسط هي O(n log n) بثوابت صغيرة وبتمشي على الذاكرة بشكل مريح للـ cache.
How can Frequency Sort be faster than n log n?إزاي Frequency Sort أسرع من n log n؟
The n log n lower bound applies only to sorts that decide order by comparing values. Frequency Sort counts values instead, so it costs O(n + k). The catch: it needs integers and a limited range k, and extra memory for the count table.
حد الـ n log n بينطبق بس على الخوارزميات اللي بتحدد الترتيب بمقارنة القيم. Frequency Sort بتعدّ القيم بدل كده، فتكلفتها O(n + k). العيب: محتاجة أرقام صحيحة ومدى محدود k، وذاكرة زيادة لجدول العدّ.
Is the animation speed the real speed?هل سرعة الأنيميشن هي السرعة الحقيقية؟
No. The Race shows one operation per step for every algorithm, so it compares the number of operations. Real time is measured in the Benchmark, on the server.
لأ. الـ Race بيعرض عملية واحدة في كل خطوة لكل الخوارزميات، فهو بيقارن عدد العمليات. الوقت الحقيقي بيتقاس في الـ Benchmark على السيرفر.
How do you know the results are correct?عرفتوا منين إن النتايج صح؟
Every output is compared with Python's sorted(), including duplicates. A wrong output aborts the experiment, so it can never win. Replaying a trace must rebuild the sorted array. The backend has 558 automated tests and strict type checks.
كل ناتج بيتقارن بـ sorted() بتاعة Python، ومعاه القيم المكررة. أي ناتج غلط بيوقف التجربة، فعمره ما يكسب. وإعادة تشغيل أي trace لازم تطلّع المصفوفة مترتبة. والباك إند عنده 558 test أوتوماتيك و type checking صارم.
Why are timings different every run?ليه التوقيت بيختلف كل مرة؟
The operating system, other programs, CPU frequency and the Python interpreter all add noise. That is why we use warm-ups, repeats and the median, and show a warning when results overlap. Operation counts never change.
نظام التشغيل والبرامج التانية وسرعة الـ CPU والـ Python interpreter كلهم بيضيفوا تشويش (noise). عشان كده بنستخدم warm-up وتكرار والـ median، وبنعرض تحذير لما النتايج تتداخل. أما عدد العمليات فعمره ما بيتغير.
Why only 128 values in the Race?ليه 128 قيمة بس في الـ Race؟
A trace stores every operation. Bubble Sort on 1,000 values would make hundreds of thousands of events: too big to send and too long to watch. 128 values and 20,000 events per algorithm keep it readable and fast.
الـ trace بيخزن كل عملية. Bubble Sort على 1,000 قيمة هيعمل مئات الآلاف من الـ events: كبير جدًا عشان يتبعت وطويل جدًا عشان يتشاف. 128 قيمة و 20,000 event لكل خوارزمية بيخلّوه مقروء وسريع.
Why is Insertion Sort stable but Selection Sort is not?ليه Insertion Sort مستقرة و Selection Sort لأ؟
Insertion Sort shifts only values strictly greater than the key, so equal values never pass each other. Selection Sort swaps the minimum into place across a long distance, which can jump over an equal value.
Insertion Sort بتزق بس القيم اللي أكبر من الـ key، فالقيم المتساوية عمرها ما بتعدّي على بعض. Selection Sort بتبدّل أصغر قيمة لمكانها من مسافة بعيدة، وده ممكن ينط فوق قيمة مساوية ليها.
Why FastAPI and React?ليه FastAPI و React؟
FastAPI gives request validation and an OpenAPI schema for free, and the algorithms are naturally written in Python. The frontend generates its TypeScript types from that schema, so client and server cannot drift apart silently. React fits an interactive, state-heavy page like the Race.
FastAPI بيدّيك validation للطلبات و OpenAPI schema جاهزين، والخوارزميات بتتكتب بالـ Python بشكل طبيعي. والفرونت بيولّد الـ TypeScript types من الـ schema دي، فالكلاينت والسيرفر مش ممكن يختلفوا عن بعض من غير ما ناخد بالنا. و React مناسب لصفحة تفاعلية فيها state كتير زي الـ Race.
How would you add a new algorithm?لو عايز تضيف خوارزمية جديدة تعمل إيه؟
Write one module in backend/src/algorithms/ with its metadata (id, name, complexity, stable, in place) and a sort(context) function that uses the context for every compare, swap and write, then register it. The API, the Race and the charts pick it up automatically.
تكتب module واحد في backend/src/algorithms/ فيه الـ metadata بتاعتها (الـ id والاسم والتعقيد و stable و in place) ودالة sort(context) بتستخدم الـ context في كل مقارنة وتبديل وكتابة، وبعدين تسجّلها. الـ API والـ Race والشارتس هياخدوها لوحدهم.
What happens if many people use it at once?لو ناس كتير استخدموه في نفس الوقت يحصل إيه؟
Experiments wait in a queue of at most 4. Beyond that the API answers 503 execution_busy and the page shows "The server is busy, try again in a moment". Limits are checked before work starts, so one huge request cannot freeze the server.
التجارب بتستنى في طابور أقصاه 4. لو زاد عن كده الـ API بيرد بـ 503 execution_busy والصفحة بتقول إن السيرفر مشغول وجرّب كمان شوية. والحدود بتتراجع قبل ما الشغل يبدأ، فطلب واحد ضخم مش ممكن يوقّف السيرفر.
Is there a database?فيه database؟
No. The API is stateless: no accounts, no stored history. Every experiment is reproducible from its seed and settings, so nothing needs saving yet.
لأ. الـ API مش بيحفظ حالة (stateless): مفيش حسابات ولا تاريخ محفوظ. أي تجربة ممكن تتعاد من الـ seed والإعدادات بتاعتها، فمفيش حاجة محتاجة تتحفظ لحد دلوقتي.
Glossary
قاموس المصطلحات
English term, what it means, and how to say it in Arabic.
المصطلح بالإنجليزي، ومعناه، وتقوله إزاي بالعربي.
| English | Meaning | المعنى | العربية |
|---|---|---|---|
| Algorithm | A precise list of steps that solves a problemخطوات محددة بتحل مشكلة | خوارزمية | |
| Array | An ordered list of values with positions (indices)ليستة قيم مترتبة ليها أماكن (indices) | مصفوفة | |
| Index | A position in the array, starting at 0مكان في المصفوفة، بيبدأ من 0 | فهرس / موضع | |
| Comparison | Checking which of two values is biggerنشوف أنهي قيمة أكبر من التانية | مقارنة | |
| Swap | Two positions exchange valuesمكانين بيبدّلوا قيمهم | تبديل | |
| Write | Putting a value into a positionنحط قيمة في مكان | كتابة | |
| Time complexity | How the work grows with nالشغل بيكبر إزاي مع n | التعقيد الزمني | |
| Space complexity | How much extra memory is neededمحتاج ذاكرة زيادة قد إيه | التعقيد المكاني | |
| Best / average / worst case | Cost on the friendliest, typical and hardest inputالتكلفة على أسهل input وعلى العادي وعلى أصعب واحد | أفضل / متوسط / أسوأ حالة | |
| Stable | Equal values keep their orderالقيم المتساوية بتفضل بترتيبها | مستقرة | |
| In place | Sorts inside the same arrayبترتب جوه نفس المصفوفة | في نفس المكان | |
| Pivot | The value Quick Sort splits aroundالقيمة اللي Quick Sort بيقسم حواليها | المحور | |
| Partition | Splitting into smaller / equal / larger partsالتقسيم لأجزاء أصغر ومساوية وأكبر | تقسيم | |
| Heap | A tree where every parent ≥ its childrenشجرة كل أب فيها أكبر من أو يساوي أولاده | كومة (heap) | |
| Trace / event | The recorded list of operations / one operation in itليستة العمليات المتسجلة / عملية واحدة فيها | تتبع / حدث | |
| Benchmark | Measuring performance under controlled conditionsقياس الأداء في ظروف متحكم فيها | قياس أداء | |
| Median | The middle value after sorting the samplesالقيمة اللي في النص بعد ترتيب العينات | الوسيط | |
| Warm-up | Untimed runs before measuringتشغيلات من غير توقيت قبل القياس | إحماء | |
| Seed | A number that makes random data repeatableرقم بيخلّي الداتا العشوائية تتكرر بنفس الشكل | بذرة | |
| Endpoint | One API address, like POST /api/v1/sortعنوان واحد في الـ API، زي POST /api/v1/sort | نقطة وصول | |
| Worker process | A separate program that does the heavy workبرنامج منفصل بيعمل الشغل التقيل | عملية عاملة | |
| Stateless | Keeps no memory between requestsمش بيفتكر حاجة بين الطلبات | عديم الحالة |