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

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

English

Binary search

The array is sorted and has n elements. Return the index of target, or -1 if it isn't present. Keep lo and hi bounds, check the middle each step, and discard the half that can't contain the target.

עברית

חיפוש בינארי

המערך מסודר ויש בו n אלמנטים. החזר את האינדקס של target, או -1 אם הוא אינו קיים. שמור על גבולות lo ו-hi, בדוק את האמצע בכל צעד, והסר את החצי שאינו יכול להכיל את היעד.

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

IGCSE, A-Level & AP