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

Searching: linear and binary · ⁨חיפוש: ליניארי ובין-מונדי⁩

English

Finding a value

  • A common job is to search: is a value in an array, and where?
  • The usual answer is the index where we found it, or -1 if it is not there.
  • We learn two ways: linear search (works on any array) and binary search (needs a sorted array, but is much faster).
עברית

מציאת ערך

  • משימה נפוצה היא חיפוש: האם ערך קיים במערך, ואם כן, איפה?
  • התשובה המקובלת היא המדד שבו נמצא, או -1 אם אינו קיים.
  • לומדים שתי דרכים: חיפוש ליניארי (עובד בכל מערך) וחיפוש בינארי (דורש מערך מוצע, אך מהיר משמעותית).

Handout · ⁨חומר עזר⁩

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

IGCSE, A-Level & AP