Sorting - When and Which
ראיון ב-Booking.com, 2022: "Sort a nearly sorted array where every element is at most k positions away from its sorted position." מועמד שלקח Merge Sort - O(n log n), עם הערה "זה מספיק". מועמד שהכיר Heap Sort על k-sorted arrays - O(n log k), מהיר בהרבה כש-k קטן. בראיון, לדעת מתי להשתמש בכל Algorithm זה מה שנבדק - לא רק היישום.
Sorting הוא נושא שנראה "בסיסי" עד שמתחילים לשאול את השאלות הנכונות. "מדוע Python's sort הוא Stable?" "מתי Counting Sort עדיף?" "מה ה-Worst Case של Quick Sort ואיך מונעים אותו?" אלה שאלות שמראיינים אוהבים לשאול כי הן מפרידות בין מי שזוכר שמות לבין מי שמבין מנגנונים.
Sorting הוא לא רק "sort(arr)". זה Pattern Recognition: מיון לאחסון, מיון לחיפוש, Custom Comparator, Counting Sort לאיברים קטנים, ו-Heap Sort לnear-sorted data.