Skip to content · ⁨דלג לתוכן⁩

Binary search · ⁨חיפוש ביינארי⁩

English

Binary search

The array is sorted. Return the index of target, or -1 if it isn't there. Binary search halves the range each step: check the middle element, then keep looking in just the left or right half. Far faster than scanning every element.

עברית

חיפוש בינארי

המערך מסודר. החזר את האינדקס של target, או -1 אם אינו קיים. חיפוש בינארי מחלק את הטווח למחצית בכל צעד: בדוק את האלמנט במרכז, ולאחר מכן המשך לחפש רק בחצי השמאלי או הימני. זה הרבה מהר יותר מסריקה של כל אלמנט.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP