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

Algorithms and Programming · ⁨אלגוריתמים ותכנות⁩

AP Computer Science Principles · ⁨עקרונות מדעי המחשב - AP⁩ · Topic 3 · ⁨נושא 3⁩

Video lesson for this topic · ⁨שיעור וידאו לנושא זה⁩ Open the video page · ⁨פתח את עמוד הוידאו⁩
9:17

אלגוריתמים ותכנות

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

English narration · English + 中文 subtitles burned in · ⁨קריאת קול באנגלית · תרגום אנגלי + סינית שרוף בתוך הסרטון⁩

English

Code below uses the AP CSP pseudocode – the exam's language-neutral reference. Assignment is written a ← expression, and list indices start at 1.

עברית

הקוד למטה משתמש ב-伪代码 AP CSP – ההערכה הייחוסית הניטרלית בשפה. ההקצה נכתב a ← expression, והמדדים ברשימה מתחילים ב-1.

3.1

Variables and Assignments · ⁨משתנים והקצאות⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-1): To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways.

Learning Objective AAP-1.A: Represent a value with a variable. [Skill 3.A]

  • AAP-1.A.1 A variable is an abstraction inside a program that can hold a value. Each variable has associated data storage that represents one value at a time, but that value can be a list or other collection that in turn contains multiple values.
  • AAP-1.A.2 Using meaningful variable names helps with the readability of program code and understanding of what values are represented by the variables.
  • AAP-1.A.3 Some programming languages provide types to represent data, which are referenced using variables. These types include numbers, Booleans, lists, and strings.
  • AAP-1.A.4 Some values are better suited to representation using one type of datum rather than another.

Learning Objective AAP-1.B: Determine the value of a variable as a result of an assignment. [Skill 4.B]

  • AAP-1.B.1 The assignment operator allows a program to change the value represented by a variable.

  • AAP-1.B.2 The exam reference sheet provides the "$\leftarrow$" operator to use for assignment. For example,

    Text:

    a ← expression

    Block:

    a ← expression

    evaluates expression and then assigns a copy of the result to the variable a.

  • AAP-1.B.3 The value stored in a variable will be the most recent value assigned. For example:

    a ← 1 b ← a a ← 2 display(b)

    still displays 1.

עברית

הבנה מתמשכת (AAP-1): כדי למצוא פתרונות ספציפיים לבעיות הניתנות לגנרליזציה, מתכנתים מייצגים ומארגנים נתונים בדרכים שונות.

מטרת למידה AAP-1.A: לייצג ערך באמצעות משתנה. [מיומנות 3.A]

  • AAP-1.A.1 משתנה הוא אבסטרקציה בתוך תוכנית שיכולה להכיל ערך. למשתנה כלשהו יש אחסון נתונים המצומד לו המייצג ערך אחד בכל פעם, אך ערך זה יכול להיות רשימה או קבוצה אחרת המכילה בתורה מספר ערכים.
  • AAP-1.A.2 השימוש בשמות משתנים משמעותיים תורם לקריאות הקוד ולהבנת הערכים המיוצגים על ידי המשתנים.
  • AAP-1.A.3 חלק מהשפות מספקות סוגי נתונים לייצוג מידע, עליהם נתייחס באמצעות משתנים. סוגים אלו כוללים מספרים, בוליאנים, רשימות ומחרוזות.
  • AAP-1.A.4 לערכים מסוימים יש ייצוג טוב יותר באמצעות סוג נתונים אחד בהשוואה לסוג אחר.

מטרת למידה AAP-1.B: לקבוע את ערך משתנה כתוצאה ממינון. [מיומנות 4.B]

  • AAP-1.B.1 אופרטור המינון מאפשר לתוכנית לשנות את הערך המיוצג על ידי משתנה.

  • AAP-1.B.2 דף ההפניות לבחין מספק את האופרטור "$\leftarrow$" לשימוש במינון. לדוגמה,

    טקסט:

    a ← expression

    בלוק:

    a ← expression

    מחשב expression ולאחר מכן ממין העתקה של התוצאה למשתנה a.

  • AAP-1.B.3 הערך המאוחסן במשתנה יהיה הערך שהמין אותו לאחרונה. לדוגמה:

    a ← 1 b ← a a ← 2 display(b)

    עדיין מציג 1.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A variable 变量 is a named place that holds a value. The assignment 赋值 operator stores the value on the right into the variable on the left:

A variable holds one value at a time; assigning again replaces it. Variables let a program store input, remember results, and reuse them.

עברית

משתנה הוא מקום בעל שם המוחזק בו ערך. מפעיל ההקצה מאחסן את הערך בצד ימי לתוך המשתנה בצד שמالي:

משתנה הוא מקום אחסון בעל שם שערכו יכול להשתנות
משתנה הוא אחסון בעל שם שערכו יכול להשתנות
a ← 5
b ← a + 3      // b is now 8

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

Explore · ⁨חקור⁩

Watch a variable hold and change its value · ⁨צפו במשתנה ששומר ומשנה את ערכו⁩

A variable is a named box that stores one value at a time. An assignment copies a value into the box; assigning again overwrites whatever was there. · ⁨משתנה הוא תיבה עם שם שאוחדת ערך אחד בכל פעם. הקצה מעתיקה ערך לתוך התיבה; הקצה חוזרת כוססת כל מה שהיה שם.⁩

Vocabulary · ⁨מילון מונחים⁩ Train · ⁨אימון⁩
English עברית
variable/ˈveərɪəbl/ משתנה
assignment/əˈsaɪnmənt/ הקצה
Data abstraction/ˈdeɪtə əbˈstrækʃn/ השחתת נתונים
remainder/rɪˈmeɪndə/ שארית
string/strɪŋ/ מחרוזת
concatenation/kənˌkætəˈneɪʃn/ הדבקה
Boolean expression/ˈbuːlɪən ekˈspreʃn/ ביטוי בוליאני
conditional (selection)/kənˈdɪʃənl/ תנאי (בחירה)
nested conditional/ˈnestɪd kənˈdɪʃənl/ תנאי מצטלב
Iteration (a loop)/ˌɪtəˈreɪʃn/ איטרציה (לולאה)
infinite loop/ˈɪnfɪnət luːp/ לולאת אינסוף
algorithm/ˈælɡərɪθəm/ אלגוריתם
list/lɪst/ רשימה
3.2

Data Abstraction · ⁨הלכידות נתונים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-1): To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways.

Learning Objective AAP-1.C: Represent a list or string using a variable. [Skill 3.A]

  • AAP-1.C.1 A list is an ordered sequence of elements. For example,

    [value1, value2, value3, ...]

    describes a list where value1 is the first element, value2 is the second element, value3 is the third element, and so on.

  • AAP-1.C.2 An element is an individual value in a list that is assigned a unique index.

  • AAP-1.C.3 An index is a common method for referencing the elements in a list or string using natural numbers.

  • AAP-1.C.4 A string is an ordered sequence of characters.

Learning Objective AAP-1.D: For data abstraction: a. Develop data abstraction using lists to store multiple elements. [Skill 3.B] b. Explain how the use of data abstraction manages complexity in program code. [Skill 3.C]

  • AAP-1.D.1 Data abstraction provides a separation between the abstract properties of a data type and the concrete details of its representation.

  • AAP-1.D.2 Data abstractions manage complexity in programs by giving a collection of data a name without referencing the specific details of the representation.

  • AAP-1.D.3 Data abstractions can be created using lists.

  • AAP-1.D.4 Developing a data abstraction to implement in a program can result in a program that is easier to develop and maintain.

  • AAP-1.D.5 Data abstractions often contain different types of elements.

  • AAP-1.D.6 The use of lists allows multiple related items to be treated as a single value. Lists are referred to by different names, such as array, depending on the programming language.

    • Exclusion statement (EK AAP-1.D.6): The use of linked lists is outside the scope of this course and the AP Exam.
  • AAP-1.D.7 The exam reference sheet provides the notation

    [value1, value2, value3, ...]

    to create a list with those values as the first, second, third, and so on items. For example,

    • Text:

      aList ← [value1, value2, value3, ...]

      Block:

      aList ← value1, value2, value3

      creates a new list that contains the values value1, value2, value3, and ... at indices 1, 2, 3, and ... respectively and assigns it to aList.

    • Text:

      aList ← []

      Block:

      aList ← (empty)

      creates a new empty list and assigns it to aList.

    • Text:

      aList ← bList

      Block:

      aList ← bList

      assigns a copy of the list bList to the list aList. For example, if bList contains [20, 40, 60], then aList will also contain [20, 40, 60] after the assignment.

  • AAP-1.D.8 The exam reference sheet describes a list structure whose index values are 1 through the number of elements in the list, inclusive. For all list operations, if a list index is less than 1 or greater than the length of the list, an error message is produced and the program will terminate.

עברית

הבנה מתמשכת (AAP-1): כדי למצוא פתרונות ספציפיים לבעיות הניתנות לגנרליזציה, מתכנתים מייצגים ומארגנים נתונים בדרכים שונות.

מטרת למידה AAP-1.C: נציג רשימה או מחרוזת באמצעות משתנה. [מיומנות 3.A]

  • AAP-1.C.1 רשימה היא סדרה מסודרת של אלמנטים. לדוגמה,

    [value1, value2, value3, ...]

    מתארת רשימה שבה value1 הוא האלמנט הראשון, value2 הוא האלמנט השני, value3 הוא האלמנט השלישי, וכדומה.

  • AAP-1.C.2 אלמנט הוא ערך יחיד ברשימה שמוקצה לו אינדקס ייחודי.

  • AAP-1.C.3 אינדקס הוא שיטה נפוצה להתייחס לאלמנטים ברשימה או במחרוזת באמצעות מספרים טבעיים.

  • AAP-1.C.4 מחרוזת היא סדרה מסודרת של תווים.

מטרת למידה AAP-1.D: עבור המערכת המופשטת: א. פיתוח המערכת המופשטת באמצעות רשימות לאחסון של מספר אלמנטים. [מיומנות 3.B] ב. הסבר על אופן בו השימוש בהמערכת המופשטת מנהל את המורכבות בקוד התוכנה. [מיומנות 3.C]

  • AAP-1.D.1 המערכת המופשטת מספקת הפרדה בין התכונות המופשטות של סוג הנתונים לבין פרטי ההצגה הממשיים שלה.

  • AAP-1.D.2 המערכות המופשטות מנהלות מורכבות בתוכניות על ידי מתן שמם לקבוצת נתונים ללא התייחסות לפרטים הספציפיים של ההצגה.

  • AAP-1.D.3 ניתן ליצור מערכות מופשטות באמצעות רשימות.

  • AAP-1.D.4 פיתוח המערכת המופשטת כדי לממש אותה בתוכנית עשוי לגרום לתוכנית שקלה לפיתוח ולתחזוקה.

  • AAP-1.D.5 המערכות המופשטות מכילות לעיתים אלמנטים מסוגים שונים.

  • AAP-1.D.6 השימוש ברשימות מאפשר לטפל בפריטים קשורים רבים כערך אחד. רשימות מכונות בשמות שונים, כמו מערך, בהתאם לשפת התכנות.

    • הערה על חריגות (EK AAP-1.D.6): השימוש ברשימות מקושרות מחוץ לתחום החקר של הקורס ובמבחן AP.
  • AAP-1.D.7 דף העזר לבחינה מספק את הסימון

    [value1, value2, value3, ...]

    ליצירת רשימה שבה הערכים הללו הם הפריטים הראשון, השני, השלישי, וכדומה. לדוגמה,

    • טקסט:

      aList ← [value1, value2, value3, ...]

      בלוק:

      aList ← value1, value2, value3

      יוצר רשימה חדשה המכילה את הערכים value1, value2, value3, ו... באינדקסים 1, 2, 3, ו... בהתאמה, ומיישר אותה לaList.

    • טקסט:

      aList ← []

      בלוק:

      aList ← (ריק)

      יוצר רשימה ריקה חדשה ומטיל אותה ל-aList.

    • טקסט:

      aList ← bList

      בלוק:

      aList ← bList

    מקצה העתק של הרשימה bList לרשימה aList. לדוגמה, אם bList מכילה [20, 40, 60], אזי גם aList תכיל [20, 40, 60] לאחר ההקצה.

  • AAP-1.D.8 דף העזר לבחינה מתאר מבנה רשימה שבו ערכי האינדקס הם מ-1 ועד למספר האלמנטים ברשימה, כולל המספר האחרון. עבור כל פעולות הרשימה, אם אינדקס הרשימה קטן מ-1 או גדול מאורך הרשימה, מופיע הודעת שגיאה והתוכנית תופסק.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

Data abstraction 数据抽象 lets you manage complexity by giving a single name to a collection of data – for example, a list rather than dozens of separate variables. It hides detail: you use the named collection without worrying about how it is stored. Lists (below) are the course's main data abstraction.

עברית

הלכידות נתונים מאפשרת לך לנהל מורכבות על ידי מתן שם אחד לאוסף נתונים – לדוגמה, רשימה במקום עשרות משתנים נפרדים. היא מסתרת פרטים: אתה משתמש באוסף הממונה ללא דאגה כיצד הוא מאוחסן. רשימות (למטה) הן הלכידות הנתונים המרכזית בקורס.

3.3

Mathematical Expressions · ⁨ביטויים מתמטיים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.A: Express an algorithm that uses sequencing without using a programming language. [Skill 2.A]

  • AAP-2.A.1 An algorithm is a finite set of instructions that accomplish a specific task.
  • AAP-2.A.2 Beyond visual and textual programming languages, algorithms can be expressed in a variety of ways, such as natural language, diagrams, and pseudocode.
  • AAP-2.A.3 Algorithms executed by programs are implemented using programming languages.
  • AAP-2.A.4 Every algorithm can be constructed using combinations of sequencing, selection, and iteration.

Learning Objective AAP-2.B: Represent a step-by-step algorithmic process using sequential code statements. [Skill 2.B]

  • AAP-2.B.1 Sequencing is the application of each step of an algorithm in the order in which the code statements are given.
  • AAP-2.B.2 A code statement is a part of program code that expresses an action to be carried out.
  • AAP-2.B.3 An expression can consist of a value, a variable, an operator, or a procedure call that returns a value.
  • AAP-2.B.4 Expressions are evaluated to produce a single value.
  • AAP-2.B.5 The evaluation of expressions follows a set order of operations defined by the programming language.
  • AAP-2.B.6 Sequential statements execute in the order they appear in the code segment.
  • AAP-2.B.7 Clarity and readability are important considerations when expressing an algorithm in a programming language.

Learning Objective AAP-2.C: Evaluate expressions that use arithmetic operators. [Skill 4.B]

  • AAP-2.C.1 Arithmetic operators are part of most programming languages and include addition, subtraction, multiplication, division, and modulus operators.

  • AAP-2.C.2 The exam reference sheet provides a MOD b, which evaluates to the remainder when a is divided by b. Assume that a is an integer greater than or equal to 0 and b is an integer greater than 0. For example, 17 MOD 5 evaluates to 2.

  • AAP-2.C.3 The exam reference sheet provides the arithmetic operators +, -, *, /, and MOD.

    Text and Block:

    • a + b
    • a - b
    • a * b
    • a / b
    • a MOD b

    These are used to perform arithmetic on a and b. For example, 17 / 5 evaluates to 3.4.

  • AAP-2.C.4 The order of operations used in mathematics applies when evaluating expressions. The MOD operator has the same precedence as the * and / operators.

עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרת הלמידה AAP-2.A: לביטא אלגוריתם המשמש סידור ללא שימוש בשפת תכנות. [מיומנות 2.A]

  • AAP-2.A.1 אלגוריתם הוא סט סופי של הוראות שמבצע משימה ספציפית.
  • AAP-2.A.2 מעבר לשפות תכנות ויזואליות וטקסטואליות, אלגוריתמים יכולים להיות מובעים בדרכים מגוונות, כגון שפה טבעית, דיאגרמות ופסאו-קוד.
  • AAP-2.A.3 אלגוריתמים המבוצעים על ידי תוכניות ממומשים באמצעות שפות תכנות.
  • AAP-2.A.4 כל אלגוריתם יכול להיבנות באמצעות שילובים של סידור, בחירה וחזרה.

מטרת הלמידה AAP-2.B: לייצג תהליך אלגוריתמי צעד-בצעד באמצעות פקודות קוד רצף. [מיומנות 2.B]

  • AAP-2.B.1 סידור הוא היישום של כל צעד באלגוריתם בסדר שבו נתונות פקודות הקוד.
  • AAP-2.B.2 פקודת קוד היא חלק ממקוד התוכנית שמבטא פעולה ביצועית.
  • AAP-2.B.3 ביטוי יכול להורכב מערך, משתנה, אופרטור או קריאת פרוצדורה החזירה ערך.
  • AAP-2.B.4 ביטויים מוערכים כדי לייצר ערך יחיד.
  • AAP-2.B.5 הערכת ביטויים נעשית לפי סדר פעולות מוגדר על ידי שפת התכנות.
  • AAP-2.B.6 פקודות רצף מבוצעות בסדר שבו הן מופיעות בקטע הקוד.
  • AAP-2.B.7 בהירות וקריאות הן considerations חשובות כאשר מביעים אלגוריתם בשפת תכנות.

מטרת הלמידה AAP-2.C: להעריך ביטויים המשמשים אופרטורים אריתמטיים. [מיומנות 4.B]

  • AAP-2.C.1 אופרטורים אריתמטיים הם חלק מרוב שפות התכנות ומכללים אופרטורים של חיבור, חיסור, כפל, חלוקה ואופרטור מודולוס.

  • AAP-2.C.2 דף העזר לבחינה מספק a MOD b, המעריך את שארית החלוקה כאשר a מחולק ב-b. הנח כי a הוא שלם הגדול או שווה ל-0 ו-b הוא שלם הגדול מ-0. לדוגמה, 17 MOD 5 מעריך ל-2.

  • AAP-2.C.3 דף העזר לבחינה מספק את האופרטורים הארימטיים +, -, *, / ו-MOD.

    טקסט ומסגרת:

    • a + b
    • a - b
    • a * b
    • a / b
    • a MOD b

    אלו משמשים לבצע פעולות אריטמיות על a ועל b. לדוגמה, 17 / 5 מעריך ל-3.4.

  • AAP-2.C.4 סדר הפעולות המשמש במתמטיקה חל גם בהערכת ביטויים. לאופרטור MOD יש אותה עדיפות כמו לאופרטורים * ול-/.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

Programs compute with the operators +, -, *, /, and MOD (the remainder 余数 of a division, e.g. 17 MOD 5 is 2). Expressions follow the usual order of operations. MOD is especially useful for testing divisibility (n MOD 2 = 0 means n is even) and for wrapping values around a range.

עברית

תוכניות מחשבות עם הפעולונים +, -, *, /, וMOD (השארת של חילוק, למשל 17 MOD 5 הוא 2). ביטויים עוקבים אחרי סדר פעולות רגיל. MOD שימושי במיוחד לבדיקת חלוקיות (n MOD 2 = 0 פירושו שn הוא זוגי) ולעטיפת ערכים סביב טווח.

Explore · ⁨חקור⁩

Evaluate an expression step by step · ⁨חשבו ביטוי צעד אחר צעד⁩

An expression is evaluated with order of operations: multiplication and division happen before addition and subtraction, left to right. · ⁨ביטוי מוערך לפי סדר פעולות: כפל וחילוק מתבצעים לפני חיבור וחסר, משמאל לימין.⁩

3.4

Strings · ⁨מחרוזות⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.D: Evaluate expressions that manipulate strings. [Skill 4.B]

  • AAP-2.D.1 String concatenation joins together two or more strings end-to-end to make a new string.
  • AAP-2.D.2 A substring is part of an existing string.
עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרות למידה AAP-2.D: הערך ביטויים המעבדים מחרוזות. [כישור 4.B]

  • AAP-2.D.1 הצמדת מחרוזות (String concatenation) מחברת שתי מחרוזות או יותר קצה לקצה ליצירת מחרוזת חדשה.
  • AAP-2.D.2 תת-מחרוזת היא חלק ממחרוזת קיימת.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A string 字符串 is an ordered sequence of characters, like "hello". Programs join strings (concatenation 拼接) and find their length. Strings represent text – names, messages, sequences – and are a common program input and output.

עברית

מחרוזת היא רצף ממוין של תווים, כמו "hello". תוכניות מחברות מחרוזות (היתוך) ומחשבות את אורכן. מחרוזות מייצגות טקסט – שמות, הודעות, רצפים – והן קלט ופלט נפוצים בתוכניות.

3.5

Boolean Expressions · ⁨ביטויים בוליאניים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.E: For relationships between two variables, expressions, or values: a. Write expressions using relational operators. [Skill 2.B] b. Evaluate expressions that use relational operators. [Skill 4.B]

  • AAP-2.E.1 A Boolean value is either true or false.

  • AAP-2.E.2 The exam reference sheet provides the following relational operators: =, ≠, >, <, ≥, and ≤.

    Text and Block:

    • a = b
    • a ≠ b
    • a > b
    • a < b
    • a ≥ b
    • a ≤ b

    These are used to test the relationship between two variables, expressions, or values. A comparison using a relational operator evaluates to a Boolean value. For example, a = b evaluates to true if a and b are equal; otherwise, it evaluates to false.

Learning Objective AAP-2.F: For relationships between Boolean values: a. Write expressions using logical operators. [Skill 2.B] b. Evaluate expressions that use logic operators. [Skill 4.B]

  • AAP-2.F.1 The exam reference sheet provides the logical operators NOT, AND, and OR, which evaluate to a Boolean value.

  • AAP-2.F.2 The exam reference sheet provides

    Text:

    NOT condition

    Block:

    NOT condition

    which evaluates to true if condition is false; otherwise it evaluates to false.

  • AAP-2.F.3 The exam reference sheet provides

    Text:

    condition1 AND condition2

    Block:

    condition1 AND condition2

    which evaluates to true if both condition1 and condition2 are true; otherwise it evaluates to false.

  • AAP-2.F.4 The exam reference sheet provides

    Text:

    condition1 OR condition2

    Block:

    condition1 OR condition2

    which evaluates to true if condition1 is true or if condition2 is true or if both condition1 and condition2 are true; otherwise it evaluates to false.

  • AAP-2.F.5 The operand for a logical operator is either a Boolean expression or a single Boolean value.

עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרות למידה AAP-2.E: עבור קשרים בין שני משתנים, ביטויים או ערכים: א. כתוב ביטויים באמצעות אופרטורים יחסיים. [כישור 2.B] ב. הערך ביטויים המשתמשים באופרטורים יחסיים. [כישור 4.B]

  • AAP-2.E.1 ערך בוליאני הוא או נכון או שגוי.

  • AAP-2.E.2 דף העזר לבחינה מספק את אופרטורי היחס הבאים: =, ≠, >, <, ≥ ו-≤.

    טקסט ומסגרת:

    • a = b
    • a ≠ b
    • a > b
    • a < b
    • a ≥ b
    • a ≤ b

    אלו משמשים לבדוק את הקשר בין שני משתנים, ביטויים או ערכים. השוואה באמצעות אופרטור יחסי מערכי תוצאה בוליאנית. לדוגמה, a = b מעריך ל-true אם a ו-b שווים; אחרת, הוא מעריך ל-false.

מטרות למידה AAP-2.F: עבור קשרים בין ערכים בוליאניים: א. כתוב ביטויים באמצעות אופרטורים לוגיים. [כישור 2.B] ב. הערך ביטויים המשתמשים באופרטורים לוגיים. [כישור 4.B]

  • AAP-2.F.1 דף העזר לבחינה מספק את האופרטורים הלוגיים NOT, AND ו-OR, המערכים תוצאה בוליאנית.

  • AAP-2.F.2 דף העזר לבחינה מספק

    טקסט:

    NOT condition

    בלוק:

    NOT condition

    שמעריך true אם condition הוא false; אחרת מעריך false.

  • AAP-2.F.3 דף העזר לבחינה מספק

    טקסט:

    condition1 AND condition2

    בלוק:

    condition1 AND condition2

    שמעריך true אם גם condition1 וגם condition2 הם true; אחרת מעריך false.

  • AAP-2.F.4 דף העזר לבחינה מספק

    טקסט:

    condition1 OR condition2

    בלוק:

    condition1 OR condition2

    שמעריך true אם condition1 הוא true או אם condition2 הוא true או אם גם condition1 וגם condition2 הם true; אחרת מעריך false.

  • AAP-2.F.5 האופרנד של אופרטור לוגי הוא ביטוי בוליאני או ערך בוליאני יחיד.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A Boolean expression 布尔表达式 evaluates to true or false. It uses relational operators (=, ≠, <, >, ≤, ≥) and logical operators NOT, AND, OR:

  • NOT reverses a value,
  • AND is true only when both sides are true,
  • OR is true when at least one side is true.

These conditions drive every decision and loop.

עברית

ביטוי בוליאני מתאפיין בתוצאה של true או false. הוא משתמש באופרטורי יחס (=, ≠, <, >, ≤, ≥) ובאופרטורים לוגיים NOT, AND, OR:

שלושת משפחות המפעילים: אריתמטי, יחסי ולוגי
שלושת משפחות המפעילים: אריתמטי, יחסי ולוגי
  • NOT הופך ערך לחיובי/שלילי (או להפוך),
  • AND נכון רק כאשר שני הצדדים נכונים,
  • OR נכון כאשר לפחות אחד מהצדדים נכון.

תנאים אלו מנהלים כל החלטה ולולאה.

Explore · ⁨חקור⁩

Try the OR truth table · ⁨נסו טבלת אמת של OR⁩

A Boolean expression is either true (1) or false (0). OR is true when at least one input is true; flip the inputs to see every case. · ⁨ביטוי בוליאני הוא או נכון (1) או שגוי (0). OR הוא נכון כאשר לפחות אחד מהקלטים הוא נכון; הפכו את הקלטים כדי לראות כל מקרה.⁩

3.6

Conditionals · ⁨תנאים (בחירה)⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.G: Express an algorithm that uses selection without using a programming language. [Skill 2.A]

  • AAP-2.G.1 Selection determines which parts of an algorithm are executed based on a condition being true or false.

Learning Objective AAP-2.H: For selection: a. Write conditional statements. [Skill 2.B] b. Determine the result of conditional statements. [Skill 4.B]

  • AAP-2.H.1 Conditional statements, or "if-statements," affect the sequential flow of control by executing different statements based on the value of a Boolean expression.

  • AAP-2.H.2 The exam reference sheet provides

    Text:

    IF(condition) { <block of statements> }

    Block:

    IF condition block of statements

    in which the code in block of statements is executed if the Boolean expression condition evaluates to true; no action is taken if condition evaluates to false.

  • AAP-2.H.3 The exam reference sheet provides

    Text:

    IF(condition) { <first block of statements> } ELSE { <second block of statements> }

    Block:

    IF condition first block of statements ELSE second block of statements

    in which the code in first block of statements is executed if the Boolean expression condition evaluates to true; otherwise, the code in second block of statements is executed.

עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרות למידה AAP-2.G: לבטא אלגוריתם המשתמש בבחירה ללא שימוש בשפת תכנות. [מיומנות 2.A]

  • AAP-2.G.1 בחירה קובעת אילו חלקים מאלגוריתם יוצאו לפועל בהתבסס על כך שהתנאי הוא true או false.

מטרות למידה AAP-2.H: עבור בחירה: א. כתוב הודעות תנائية. [מיומנות 2.B] ב. קבע את התוצאה של הודעות תנائية. [מיומנות 4.B]

  • AAP-2.H.1 הודעות תנائية, או "הודעות if", משפיעות על הזרימה הרצף של השליטה על ידי ביצוע הודעות שונות בהתבסס על ערך הביטוי הבוליאני.

  • AAP-2.H.2 דף העזר לבחינה מספק

    טקסט:

    IF(condition) { <block of statements> }

    בלוק:

    IF condition block of statements

    שבו הקוד בblock of statements יוצא לפועל אם הביטוי הבוליאני condition מעריך true; אין פעולה כלשהי אם condition מעריך false.

  • AAP-2.H.3 דף העזר לבחינה מספק

    טקסט:

    IF(condition) { <first block of statements> } ELSE { <second block of statements> }

    בלוק:

    IF condition first block of statements ELSE second block of statements

    שבו הקוד בfirst block of statements יוצא לפועל אם הביטוי הבוליאני condition מעריך true; אחרת, הקוד בsecond block of statements יוצא לפועל.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A conditional (selection) 条件语句 chooses which code to run. IF runs a block only when its condition is true; ELSE gives an alternative:

עברית

תנאי (בחירה) קובעים איזה קוד יוצא לפועל. IF מפעיל בלוק רק כאשר התנאי שלו נכון; ELSE מציע חלופה:

בחירה בין מסלולים בהתאם לתנאי
הבחירה בוחנת בין מסלולים על בסיס תנאי
IF (score ≥ 60)
{
    DISPLAY("Pass")
}
ELSE
{
    DISPLAY("Fail")
}
Explore · ⁨חקור⁩

Follow an if / else decision · ⁨עקבו אחרי החלטה של if / else⁩

A conditional runs one branch or another depending on whether its condition is true. Slide the value across the threshold and watch which branch is taken. · ⁨תנאי מבצע ענף אחד או אחר בהתאם לכך האם התנאי שלו נכון. הזיזו את הערך מעבר לסף וצפו באיזה ענף נלקח.⁩

3.7

Nested Conditionals · ⁨תנאים מקוננים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.I: For nested selection: a. Write nested conditional statements. [Skill 2.B] b. Determine the result of nested conditional statements. [Skill 4.B]

  • AAP-2.I.1 Nested conditional statements consist of conditional statements within conditional statements.
עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרות למידה AAP-2.I: עבור בחירה מקושרת: א. כתוב תנאים מודגשים. [מיומנות 2.B] ב. קבע את התוצאה של תנאים מודגשים. [מיומנות 4.B]

  • AAP-2.I.1 תנאים מודגשים מכילים תנאים בתוך תנאים.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A nested conditional 嵌套条件 places one IF inside another (or chains ELSE IF) to choose among more than two paths. Only the first matching branch runs:

עברית

תנאי מקונן מציב IF אחד בתוך אחר (או מקשר ELSE IF) כדי לבחור בין יותר משני מסלולים. רק הערוכה הראשונה המתאימה תופעל:

IF (g ≥ 90)      { grade ← "A" }
ELSE IF (g ≥ 80) { grade ← "B" }
ELSE             { grade ← "C" }
3.8

Iteration · ⁨איטרציה⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.J: Express an algorithm that uses iteration without using a programming language. [Skill 2.A]

  • AAP-2.J.1 Iteration is a repeating portion of an algorithm. Iteration repeats a specified number of times or until a given condition is met.

Learning Objective AAP-2.K: For iteration: a. Write iteration statements. [Skill 2.B] b. Determine the result or side effect of iteration statements. [Skill 4.B]

  • AAP-2.K.1 Iteration statements change the sequential flow of control by repeating a set of statements zero or more times, until a stopping condition is met.

  • AAP-2.K.2 The exam reference sheet provides

    Text:

    REPEAT n TIMES { <block of statements> }

    Block:

    REPEAT n TIMES block of statements

    in which the block of statements is executed n times.

  • AAP-2.K.3 The exam reference sheet provides

    Text:

    REPEAT UNTIL(condition) { <block of statements> }

    Block:

    REPEAT UNTIL condition block of statements

    in which the code in block of statements is repeated until the Boolean expression condition evaluates to true.

  • AAP-2.K.4 In REPEAT UNTIL(condition) iteration, an infinite loop occurs when the ending condition will never evaluate to true.

  • AAP-2.K.5 In REPEAT UNTIL(condition) iteration, if the conditional evaluates to true initially, the loop body is not executed at all, due to the condition being checked before the loop.

עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרת למידה AAP-2.J: מבטא אלגוריתם המשתמש באיטרציה ללא שימוש בשפת תכנות. [מיומנות 2.A]

  • AAP-2.J.1 איטרציה היא חלק חוזר באלגוריתם. האיטרציה חוזרת מספר פעמים ספציפי או עד שהתנאי הנתון מתקיים.

מטרת למידה AAP-2.K: לגבי איטרציה: א. כתוב פקודות איטרציה. [מיומנות 2.B] ב. קבע את התוצאה או ההשפעה המשנית של פקודות איטרציה. [מיומנות 4.B]

  • AAP-2.K.1 פקודות איטרציה משנות את זרימת הבקרה הרציף על ידי חזרה על סט של פקודות אפס או יותר פעמים, עד שהתנאי העצירה מתקיים.

  • AAP-2.K.2 דף ההפניות לבחינה מספק

    טקסט:

    REPEAT n TIMES { <block of statements> }

    בלוק:

    REPEAT n TIMES block of statements

    שבו block of statements מופעל n פעמים.

  • AAP-2.K.3 דף ההפניות לבחינה מספק

    טקסט:

    REPEAT UNTIL(condition) { <block of statements> }

    בלוק:

    REPEAT UNTIL condition block of statements

    שבו הקוד בblock of statements חוזר עד שהביטוי הבוליאני condition מתאפשר לtrue.

  • AAP-2.K.4 באיטרציה REPEAT UNTIL(condition), לולאה אינסופית נוצרת כאשר התנאי הסיום לעולם לא יתאפשר לtrue.

  • AAP-2.K.5 באיטרציה REPEAT UNTIL(condition), אם התנאי מתאפשר לtrue בהתחלה, גוף הלולאה לא יופעל כלל, בשל בדיקת התנאי לפני הלולאה.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

Iteration (a loop) 迭代 repeats instructions. AP pseudocode has two forms:

A loop that never meets its stopping condition is an infinite loop 无限循环.

עברית

איטרציה (לולאה) חוזרת על הוראות. פסאודוקוד AP כולל שני צורות:

לולאת תנאי מקדים (WHILE) בודקת לפני הגוף, ולכן ייתכן שתפעיל אפס פעמים
לולאת תנאי מקדים (WHILE) בודקת לפני הגוף, ולכן ייתכן שתפעיל אפס פעמים
REPEAT 5 TIMES        // a fixed count
{
    DISPLAY("hi")
}

REPEAT UNTIL (found)  // until a condition becomes true
{
    ...
}

לולאה לעולם לא נפגשת בתנאי ההפסקה שלה היא לולאה אינסופית.

Explore · ⁨חקור⁩

Trace a loop one pass at a time · ⁨עקבו אחר לולאה מעבר אחר מעבר⁩

A loop repeats a block while its counter runs through a range. Step through to watch the counter and the running total update each pass. · ⁨לולאה מחזירה על עצמה בלוק בזמן שהמונה שלה עובר בטווח. צעדו קדימה כדי לצפות שהמונה והסכום המצטבר יתעדכנו בכל מעבר.⁩

3.9

Developing Algorithms · ⁨פיתוח אלגוריתמים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.L: Compare multiple algorithms to determine if they yield the same side effect or result. [Skill 1.D]

  • AAP-2.L.1 Algorithms can be written in different ways and still accomplish the same tasks.
  • AAP-2.L.2 Algorithms that appear similar can yield different side effects or results.
  • AAP-2.L.3 Some conditional statements can be written as equivalent Boolean expressions.
  • AAP-2.L.4 Some Boolean expressions can be written as equivalent conditional statements.
  • AAP-2.L.5 Different algorithms can be developed or used to solve the same problem.

Learning Objective AAP-2.M: For algorithms: a. Create algorithms. [Skill 2.A] b. Combine and modify existing algorithms. [Skill 2.B]

  • AAP-2.M.1 Algorithms can be created from an idea, by combining existing algorithms, or by modifying existing algorithms.
  • AAP-2.M.2 Knowledge of existing algorithms can help in constructing new ones. Some existing algorithms include:
    • determining the maximum or minimum value of two or more numbers
    • computing the sum or average of two or more numbers
    • identifying if an integer is or is not evenly divisible by another integer
    • determining a robot's path through a maze
  • AAP-2.M.3 Using existing correct algorithms as building blocks for constructing another algorithm has benefits such as reducing development time, reducing testing, and simplifying the identification of errors.
עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרת למידה AAP-2.L: השוואה בין מספר אלגוריתמים כדי לקבוע האם הם מייצרים אותה השפעה משנית או תוצאה. [מיומנות 1.D]

  • AAP-2.L.1 ניתן לכתוב אלגוריתמים בצורות שונות ועדיין לבצע את אותן משימות.
  • AAP-2.L.2 אלגוריתמים שנראים זהים עשויים לייצר השפעות משניות או תוצאות שונות.
  • AAP-2.L.3 ניתן לכתוב חלק מההצהרות התנודתיות כביטויים בוליאניים שקולים.
  • AAP-2.L.4 ניתן לכתוב חלק מהביטויים הבוליאניים כהצהרות תנודתיות שקולות.
  • AAP-2.L.5 ניתן לפתח או להשתמש באלגוריתמים שונים כדי לפתור את אותו בעיה.

מטרת לימוד AAP-2.M: עבור אלגוריתמים: א. יצירת אלגוריתמים. [מיומנות 2.A] ב. מיזוג ועריכה של אלגוריתמים קיימים. [מיומנות 2.B]

  • AAP-2.M.1 ניתן ליצור אלגוריתמים מתוך רעיון, על ידי מיזוג של אלגוריתמים קיימים, או על ידי עריכת אלגוריתמים קיימים.
  • AAP-2.M.2 ידע של אלגוריתמים קיימים יכול לעזור בבניית אלגוריתמים חדשים. בין האלגוריתמים הקיימים נכללים:
    • מציאת הערך המקסימלי או המינימלי של שני מספרים או יותר
    • חישוב הסכום או הממוצע של שני מספרים או יותר
    • זיהוי אם מספר שלם מתחלק במספר שלם אחר בשווה (ללא שארית)
    • קביעת מסלול של רובוט בתוך מבוך
  • AAP-2.M.3 השימוש באלגוריתמים קיימים ונכונים כבלוקי בנייה לבניית אלגוריתם אחר מביא יתרונות כמו צמצום זמן הפיתוח, צמצום בדיקות והקלת זיהוי שגיאות.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

An algorithm is not the same thing as code. Beyond visual and textual programming languages, an algorithm can be expressed in a variety of ways: in natural language (ordinary sentences), as a diagram such as a flowchart, or in pseudocode. Those forms are for people — they let you check the logic and agree on it before any language is chosen, and the same algorithm can then be written in any language.

When you do write it in a programming language, clarity and readability are important considerations, not decoration: meaningful variable names, consistent indentation and comments explaining why rather than what. The program has to be read and modified later by someone — often you — and an algorithm nobody can follow cannot be maintained or debugged.

An algorithm 算法 is a finite sequence of steps that solves a problem, built from sequencing, selection, and iteration. Different algorithms can solve the same problem, and you should be able to combine and modify existing algorithms (for example, count the values in a list that meet a condition, or find the largest). Trace an algorithm by hand to check it is correct.

עברית
קוד מקור Python במסך — אלגוריתמים הם הוראות מדויקות וממוינות
קוד מקור Python במסך — אלגוריתמים הם הוראות מדויקות וממוינות

אלגוריתם אינו אותו דבר כמו קוד. מעבר לשפות תכנות ויזואליות וטקסטואליות, אלגוריתם ניתן לביטוי במגוון דרכים: בשפה טבעית (משפטים רגילים), כתרשים כגון סכמת זרימה, או בפסאודוקוד. צורות אלו נועדו לאנשים — הן מאפשרות לבדוק את הלוגיקה ולהתכנס עליה לפני בחירת שפת תכנות כלשהי, ולאחר מכן ניתן לכתוב את אותו אלגוריתם בכל שפה.

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

אלגוריתם הוא סדרה סופית של שלבים הפותרים בעיה, המורכבת מסידור, בחירה ואיטרציה. אלגוריתמים שונים יכולים לפתור את אותה בעיה, ועליכם להיות מסוגלים לשלב ולשנות אלגוריתמים קיימים (למשל, לספור את הערכים ברשימה העומדים בתנאי מסוים, או למצוא את הגדול ביותר). לבצע מעקב ידני אחר אלגוריתם כדי לוודא שהוא נכון.

סכמת זרימה מציגה אלגוריתם באמצעות הסמלים הסטנדרטיים
סכמת זרימה מציגה אלגוריתם באמצעות הסמלים הסטנדרטיים
3.10

Lists · ⁨רשימות⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.N: For list operations: a. Write expressions that use list indexing and list procedures. [Skill 2.B] b. Evaluate expressions that use list indexing and list procedures. [Skill 4.B]

  • AAP-2.N.1 The exam reference sheet provides basic operations on lists, including:
    • accessing an element by index

      Text:

      aList[i]

      Block:

      aList i

      accesses the element of aList at index i. The first element of aList is at index 1 and is accessed using the notation aList[1].

    • assigning a value of an element of a list to a variable

      Text:

      x ← aList[i]

      Block:

      x ← aList i

      assigns the value of aList[i] to the variable x.

    • assigning a value to an element of a list

      Text:

      aList[i] ← x

      Block:

      aList i ← x

      assigns the value of x to aList[i].

      Text:

      aList[i] ← aList[j]

      Block:

      aList i ← aList j

      assigns the value of aList[j] to aList[i].

    • inserting elements at a given index

      Text:

      INSERT(aList, i, value)

      Block:

      INSERT aList, i, value

      shifts to the right any values in aList at indices greater than or equal to i. The length of the list is increased by 1, and value is placed at index i in aList.

    • adding elements to the end of the list

      Text:

      APPEND(aList, value)

      Block:

      APPEND aList, value

      increases the length of aList by 1, and value is placed at the end of aList.

    • removing elements

      Text:

      REMOVE(aList, i)

      Block:

      REMOVE aList, i

      removes the item at index i in aList and shifts to the left any values at indices greater than i. The length of aList is decreased by 1.

    • determining the length of a list

      Text:

      LENGTH(aList)

      Block:

      LENGTH aList

      evaluates to the number of elements currently in aList.

  • AAP-2.N.2 List procedures are implemented in accordance with the syntax rules of the programming language.

Learning Objective AAP-2.O: For algorithms involving elements of a list: a. Write iteration statements to traverse a list. [Skill 2.B] b. Determine the result of an algorithm that includes list traversals. [Skill 4.B]

  • AAP-2.O.1 Traversing a list can be a complete traversal, where all elements in the list are accessed, or a partial traversal, where only a portion of elements are accessed.

    • Exclusion statement (EK AAP-2.O.1): Traversing multiple lists at the same time using the same index for both (parallel traversals) is outside the scope of this course and the AP Exam.
  • AAP-2.O.2 Iteration statements can be used to traverse a list.

  • AAP-2.O.3 The exam reference sheet provides

    Text:

    FOR EACH item IN aList { <block of statements> }

    Block:

    FOR EACH item IN aList block of statements

    The variable item is assigned the value of each element of aList sequentially, in order, from the first element to the last element. The code in block of statements is executed once for each assignment of item.

  • AAP-2.O.4 Knowledge of existing algorithms that use iteration can help in constructing new algorithms. Some examples of existing algorithms that are often used with lists include:

    • determining a minimum or maximum value in a list
    • computing a sum or average of a list of numbers
  • AAP-2.O.5 Linear search or sequential search algorithms check each element of a list, in order, until the desired value is found or all elements in the list have been checked.

עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרת למידה AAP-2.N: עבור פעולות על רשימות: א. כתיבת ביטויים המשמשים אינדקסינג של רשימה ופעולות על רשימות. [מיומנות 2.B] ב. חישוב ביטויים המשמשים אינדקסינג של רשימה ופעולות על רשימות. [מיומנות 4.B]

  • AAP-2.N.1 דף ההפניות לבחין מספק פעולות בסיסיות על רשימות, כולל:
    • גישה לאלמנט באמצעות אינדקס

      טקסט:

      aList[i]

      בלוק:

      aList i

      מגיע אל האלמנט של aList באינדקס i. האלמנט הראשון של aList נמצא באינדקס 1 ומגיעים אליו באמצעות הסימון aList[1].

    • יישום ערך של אלמנט מרשימה למשתנה

      טקסט:

      x ← aList[i]

      בלוק:

      x ← aList i

      מקצב את הערך של aList[i] למשתנה x.

    • יישום ערך לאלמנט ברשימה

      טקסט:

      aList[i] ← x

      בלוק:

      aList i ← x

      מקצב את הערך של x ל-aList[i].

      טקסט:

      aList[i] ← aList[j]

      בלוק:

      aList i ← aList j

      מקצב את הערך של aList[j] ל-aList[i].

    • הכנסת אלמנטים באינדקס נתון

      טקסט:

      INSERT(aList, i, value)

      בלוק:

      INSERT aList, i, value

      מזיז ימינה כל ערך ב-aList הנמצא באינדקסים הגדולים או שווים ל-i. אורך הרשימה עולה ב-1, והערך value מוצב באינדקס i בתוך aList.

    • הוספת אלמנטים בסוף הרשימה

      טקסט:

      APPEND(aList, value)

      בלוק:

      APPEND aList, value

      מעלה את אורך aList ב-1, והערך value מוצב בסוף aList.

    • הסרת אלמנטים

      טקסט:

      REMOVE(aList, i)

      בלוק:

      REMOVE aList, i

      מסיר את הפריט באינדקס i ב-aList ומזיז שמאלה כל ערך הנמצא באינדקסים גדולים מ-i. אורך aList קטן ב-1.

    • קביעת אורך רשימה

      טקסט:

      LENGTH(aList)

      בלוק:

      LENGTH aList

      מחזיר את מספר האלמנטים הקיימים כרגע ב-aList.

  • AAP-2.N.2 פרוצדורות רשימות מיושמות בהתאם לכללי הסינטקס של שפת התכנות.

מטרות למידה AAP-2.O: עבור אלגוריתמים המעורבים באלמנטים של רשימה: א. כתוב הודעות איטרציה כדי לעבור על רשימה. [מיומנות 2.B] ב. קבע את תוצאת האלגוריתם הכולל מעברים על רשימות. [מיומנות 4.B]

  • AAP-2.O.1 עיבר ברשימה יכול להיות עיבר מלא, בו נגישים כל האלמנטים ברשימה, או עיבר חלקי, בו נגישים רק חלק מהאלמנטים.

    • הצהרת פסילה (EK AAP-2.O.1): עיבר בו-זמני של מספר רשימות באמצעות אותו אינדקס עבור שניהן (עיבור מקביל) אינם בתחום הלימודים ובתחום המבחן AP.
  • AAP-2.O.2 ניתן להשתמש בפקודות חזרה כדי לבצע עיבר ברשימה.

  • AAP-2.O.3 דף ההפניות למבחן מספק

    טקסט:

    FOR EACH item IN aList { <block of statements> }

    בלוק:

    FOR EACH item IN aList block of statements

    המשתנה item מקבל את הערך של כל אלמנט ב-aList ברצף, בסדר, מהאלמנט הראשון ועד האחרון. הקוד ב-block of statements מתבצע פעם אחת עבור כל הצבת ערך ל-item.

  • AAP-2.O.4 ידע באלגוריתמים קיימים המשתמשים בחזרות יכול לעזור בבניית אלגוריתמים חדשים. מספר דוגמאות לאלגוריתמים קיימים הנעשים לעיתים קרובות שימוש ברשימות כוללות:

    • קביעת ערך מינימום או מקסימום ברשימה
    • חישוב סכום או ממוצע של רשימת מספרים
  • AAP-2.O.5 אלגוריתמי חיפוש ליניארי או חיפוש רציפות בוחנים כל אלמנט ברשימה, בסדר, עד שמצויה הערך הרצוי או שנבדקו כל האלמנטים ברשימה.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A list 列表 is an ordered collection of values under one name, the course's key data abstraction. AP pseudocode indexes from 1:

Traverse a list with a loop to sum, count, search, or find a maximum:

עברית

רשימה היא קבוצה מסודרת של ערכים תחת שם אחד, הה抽象ה הנתונים המרכזית של הקורס. Pseudocode ב-AP משתמש באינדקסים החל מ-1:

רשימה מחזיקה ערכים רבים במשתנה אחד, כאשר כל אחד מהם נמצא באמצעות האינדקס שלו
רשימה מחזיקה ערכים רבים במשתנה אחד, כאשר כל אחד מהם נמצא באמצעות האינדקס שלו
scores ← [88, 74, 95]
DISPLAY(scores[1])          // 88
scores[2] ← 80              // replace the 2nd value
APPEND(scores, 60)          // add to the end
INSERT(scores, 1, 100)      // insert at index 1
REMOVE(scores, 3)           // delete the 3rd element
LENGTH(scores)              // how many elements

לעבור על רשימה עם לולאה כדי לחשב סכום, לספור, לחפש או למצוא מקסימום:

FOR EACH x IN scores
{
    total ← total + x
}
3.11

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

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-2): The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective AAP-2.P: For binary search algorithms: a. Determine the number of iterations required to find a value in a data set. [Skill 1.D] b. Explain the requirements necessary to complete a binary search. [Skill 1.A]

  • AAP-2.P.1 The binary search algorithm starts at the middle of a sorted data set of numbers and eliminates half of the data; this process repeats until the desired value is found or all elements have been eliminated.
    • Exclusion statement (EK AAP-2.P.1): Specific implementations of the binary search are outside the scope of the course and the AP Exam.
  • AAP-2.P.2 Data must be in sorted order to use the binary search algorithm.
  • AAP-2.P.3 Binary search is often more efficient than sequential/linear search when applied to sorted data.
עברית

הבנה מתמשכת (AAP-2): הדרך שבה פקודות ממוינות ומשולבות בתוכנית קובעת את התוצאה המחושבת. תוכניות משלבות מבני איטרציה ובחירה כדי לייצג חזרות ולקבל החלטות כדי להתמודד עם ערכי קלט מגוונים.

מטרות למידה AAP-2.P: לגבי אלגוריתמי חיפוש בינארי: א. לקבוע את מספר החזרות הנדרשות למציאת ערך במאגר נתונים. [מיומנות 1.D] ב. להסביר את הדרישות הנדרשות להשלמת חיפוש בינארי. [מיומנות 1.A]

  • AAP-2.P.1 אלגוריתם החיפוש הבינארי מתחיל באמצע מאגר נתונים מסודר ומספרים ומסיר מחצית מהנתונים; תהליך זה חוזר על עצמו עד שמצויה הערך הרצוי או שנערכו כל האלמנטים.
    • הצהרת פסילה (EK AAP-2.P.1): יישומים ספציפיים של החיפוש הבינארי אינם בתחום הלימודים ובתחום המבחן AP.
  • AAP-2.P.2 הנתונים חייבים להיות במסודר כדי להשתמש באלגוריתם החיפוש הבינארי.
  • AAP-2.P.3 חיפוש בינארי הוא לעיתים קרובות יעיל יותר מחיפוש רציפות/ליניארי כאשר מיושם על נתונים מסודרים.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

Binary search 二分搜索 finds a value in a sorted list far faster than checking each element. It looks at the middle element, then discards the half that cannot contain the target, repeating until found. Each step halves the search space, so a list of $n$ items takes about $\log_2 n$ steps. It requires the data to be sorted first.

Worked example. Searching a sorted list of $8$ items, binary search halves the range each step: $8\rightarrow4\rightarrow2\rightarrow1$, at most $3$ comparisons ($\log_2 8=3$), whereas a linear search could take up to $8$. The advantage grows explosively: about $1{,}000$ items need only $\approx10$ binary-search steps (but up to $1{,}000$ linear ones), and $1{,}000{,}000$ items need just $\approx20$. Halving is what makes it a reasonable-time algorithm.

עברית
ספר טלפונים: חיפוש בינארי חוצה את עמודי המנוחה בשתי בחלקים בשלבים כל אחד
ספר טלפונים: חיפוש בינארי חוצה את עמודי המנוחה בשתי בחלקים בשלבים כל אחד

חיפוש בינארי מוצא ערך ברשימה ממויינת הרבה מהר יותר מלבדוק כל אלמנט. הוא בודק את האלמנט האמצעי, ומרחיק את המחצית שלא יכולה להכיל את המטרה, וחוזר על כך עד למציאתו. כל שלב חוצה את מרחב החיפוש, ולכן רשימה של $n$ פריטים לוקחת כ-$\log_2 n$ צעדים. הוא דורש שהנתונים יהיו ממוינים תחילה.

חיפוש בינארי חוצה את הטווח בכל שלב (הרשימה חייבת להיות מסודרת)
חיפוש בינארי חוצה את הטווח בכל שלב (הרשימה חייבת להיות מסודרת)

דוגמה פתורה. בחיפוש ברשימה מוסדרת של $8$ פריטים, חיפוש בינארי חוצה את הטווח בכל שלב: $8\rightarrow4\rightarrow2\rightarrow1$, עד $3$ השוואות ($\log_2 8=3$), בעוד שחיפוש ליניארי עשוי לקחת עד $8$. היתרון גדל באופן אקספוננציאלי: כ-$1{,}000$ פריטים דורשים רק $\approx10$ שלבי חיפוש בינארי (אבל עד $1{,}000$ ליניאריים), ו-$1{,}000{,}000$ פריטים דורשים רק $\approx20$. חיצוני הוא מה שהופך את זה לאלגוריתם בזמן סביר.

Vocabulary · ⁨מילון מונחים⁩ Train · ⁨אימון⁩
English עברית
Binary search/ˈbaɪnəri sɜːtʃ/ חיפוש ביינארי
3.12

Calling Procedures · ⁨קריאת הליכים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-3): Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing them to write programs more quickly and with more confidence.

Learning Objective AAP-3.A: For procedure calls: a. Write statements to call procedures. [Skill 3.B] b. Determine the result or effect of a procedure call. [Skill 4.B]

  • AAP-3.A.1 A procedure is a named group of programming instructions that may have parameters and return values.

  • AAP-3.A.2 Procedures are referred to by different names, such as method or function, depending on the programming language.

  • AAP-3.A.3 Parameters are input variables of a procedure. Arguments specify the values of the parameters when a procedure is called.

  • AAP-3.A.4 A procedure call interrupts the sequential execution of statements, causing the program to execute the statements within the procedure before continuing. Once the last statement in the procedure (or a return statement) has executed, flow of control is returned to the point immediately following where the procedure was called.

  • AAP-3.A.5 The exam reference sheet provides

    procName(arg1, arg2, ...)

    as a way to call

    Text:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> }

    Block:

    PROCEDURE procName parameter1, parameter2,... block of statements

    which takes zero or more arguments; arg1 is assigned to parameter1, arg2 is assigned to parameter2, and so on.

  • AAP-3.A.6 The exam reference sheet provides the procedure

    Text:

    DISPLAY(expression)

    Block:

    DISPLAY expression

    to display the value of expression, followed by a space.

  • AAP-3.A.7 The exam reference sheet provides the

    Text:

    RETURN(expression)

    Block:

    RETURN expression

    statement, which is used to return the flow of control to the point where the procedure was called and to return the value of expression.

  • AAP-3.A.8 The exam reference sheet provides

    result ← procName(arg1, arg2, ...)

    to assign to result the "value of the procedure" being returned by calling

    Text:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> RETURN(expression) }

    Block:

    PROCEDURE procName parameter1, parameter2,... block of statements RETURN expression

  • AAP-3.A.9 The exam reference sheet provides procedure

    Text:

    INPUT()

    Block:

    INPUT

    which accepts a value from the user and returns the input value.

עברית

הבנה מתמשכת (AAP-3): מתכננים מפצלים בעיות לחלקים קטנים ויותר ניתנים לניהול. על ידי יצירת פרוצדורות והיעזרות בפרמטרים, מתכננים ממחישים תהליכים שניתן להשתמש בהם שוב. פרוצדורות מאפשרות למתכננים להתייחס לקוד קיים שנבדק כבר, מה שמאפשר להם לכתוב תוכנות מהר יותר ובביטחון רב יותר.

מטרות למידה AAP-3.A: לגבי קריאות פרוצדורה: א. כתוב הוראות לקריאת פרוצ'ורות. [מיומנות 3.B] ב. קבע את התוצאה או ההשפעה של קריאת פרוצ'ורה. [מיומנות 4.B]

  • AAP-3.A.1 פרוצ'ורה היא קבוצה ממוענת של הוראות תכנות, העשויה להכיל פרמטרים וערכים החזרתיים.

  • AAP-3.A.2 לפרוצ'ורות ישנם שמות שונים, כגון שיטה או פונקציה, בהתאם לשפת התכנות.

  • AAP-3.A.3 פרמטרים הם משתני כניסה בפרוצ'ורה. ארגומנטים מציינים את ערכי הפרמטרים בעת קריאת הפרוצ'ורה.

  • AAP-3.A.4 קריאת פרוצ'ורה מפסיקה את הביצוע הרציף של ההוראות, וגורמת לתוכנה לבצע את ההוראות בתוך הפרוצ'ורה לפני שהיא ממשיכה. לאחר ביצוע ההוראה האחרונה בפרוצ'ורה (או הוראת החזרה), זרימת הבקרה חוזרת לנקודה המידית שלאחר הקריאה לפרוצ'ורה.

  • AAP-3.A.5 דף הייחוס למבחן מספק

    procName(arg1, arg2, ...)

    כדרך לקרוא ל-

    טקסט:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> }

    בלוק:

    PROCEDURE procName parameter1, parameter2,... block of statements

    שיש לו אפס או יותר ארגומנטים; arg1 מוגדר לparameter1, arg2 מוגדר לparameter2, וכדומה.

  • AAP-3.A.6 דף הייחוס למבחן מספק את הפרוצ'ורה

    טקסט:

    DISPLAY(expression)

    בלוק:

    DISPLAY expression

    להדפסת הערך של expression, שאחריו רווח.

  • AAP-3.A.7 דף הייחוס למבחן מספק את

    טקסט:

    RETURN(expression)

    בלוק:

    RETURN expression

    ההוראה, המשמשת להחזרת זרימת הבקרה לנקודה בה נקראה הפרוצ'ורה ולהחזרת הערך של expression.

  • AAP-3.A.8 דף הייחוס למבחן מספק

    result ← procName(arg1, arg2, ...)

    כדי להגדיר לresult את "ערך הפרוצ'ורה" שנחזר על ידי קריאת

    טקסט:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> RETURN(expression) }

    בלוק:

    PROCEDURE procName parameter1, parameter2,... block of statements RETURN expression

  • AAP-3.A.9 דף הייחוס למבחן מספק את הפרוצ'ורה

    טקסט:

    INPUT()

    בלוק:

    INPUT

    המקבלת ערך מהמשתמש ומחזירה את ערך הכניסה.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A procedure (function) 过程 is a named, reusable block of code. Calling it runs its code with the arguments you supply, and it may return a value:

Procedures let you use code without knowing its inner workings – procedural abstraction 过程抽象.

עברית

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

sum ← Add(3, 4)      // call, passing 3 and 4

הליכים מאפשרים להשתמש בקוד ללא הכרה בפנימייתו – אבסטרקציית הליכים.

3.13

Developing Procedures · ⁨פיתוח הליכים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-3): Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing them to write programs more quickly and with more confidence.

Learning Objective AAP-3.B: Explain how the use of procedural abstraction manages complexity in a program. [Skill 3.C]

  • AAP-3.B.1 One common type of abstraction is procedural abstraction, which provides a name for a process and allows a procedure to be used only knowing what it does, not how it does it.
  • AAP-3.B.2 Procedural abstraction allows a solution to a large problem to be based on the solutions of smaller subproblems. This is accomplished by creating procedures to solve each of the subproblems.
  • AAP-3.B.3 The subdivision of a computer program into separate subprograms is called modularity.
  • AAP-3.B.4 A procedural abstraction may extract shared features to generalize functionality instead of duplicating code. This allows for program code reuse, which helps manage complexity.
  • AAP-3.B.5 Using parameters allows procedures to be generalized, enabling the procedures to be reused with a range of input values or arguments.
  • AAP-3.B.6 Using procedural abstraction helps improve code readability.
  • AAP-3.B.7 Using procedural abstraction in a program allows programmers to change the internals of the procedure (to make it faster, more efficient, use less storage, etc.) without needing to notify users of the change as long as what the procedure does is preserved.

Learning Objective AAP-3.C: Develop procedural abstractions to manage complexity in a program by writing procedures. [Skill 3.B]

  • AAP-3.C.1 The exam reference sheet provides

    Text:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> }

    Block:

    PROCEDURE procName parameter1, parameter2,... block of statements

    which is used to define a procedure that takes zero or more arguments. The procedure contains block of statements.

  • AAP-3.C.2 The exam reference sheet provides

    Text:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> RETURN(expression) }

    Block:

    PROCEDURE procName parameter1, parameter2,... block of statements RETURN expression

    which is used to define a procedure that takes zero or more arguments. The procedure contains block of statements and returns the value of expression. The RETURN statement may appear at any point inside the procedure and causes an immediate return from the procedure back to the calling statement.

עברית

הבנה מתמשכת (AAP-3): מתכננים מפצלים בעיות לחלקים קטנים ויותר ניתנים לניהול. על ידי יצירת פרוצדורות והיעזרות בפרמטרים, מתכננים ממחישים תהליכים שניתן להשתמש בהם שוב. פרוצדורות מאפשרות למתכננים להתייחס לקוד קיים שנבדק כבר, מה שמאפשר להם לכתוב תוכנות מהר יותר ובביטחון רב יותר.

מטרת הלמידה AAP-3.B: הסבר כיצד השימוש באבסטרקציה פרוצ'ורלית מנהל את המורכבות בתוכנה. [מיומנות 3.C]

  • AAP-3.B.1 סוג נפוץ אחד של אבסטרקציה הוא אבסטרקציה פרוצ'ורלית, המספקת שם לתהליך ומאפשרת שימוש בפרוצ'ורה תוך ידע רק במה she does, לא איך she does it.
  • AAP-3.B.2 חילוץ הליכי (Procedural abstraction) מאפשר פתרון לבעיה גדולה לבסס על פתרונות של תת-בעיות קטנות יותר. דבר זה מתבצע על ידי יצירת הליכים לפתרון כל אחת מהתת-בעיות.
  • AAP-3.B.3 חלוקה של תוכנת מחשב לתת-תוכניות נפרדות נקראת מודולריות.
  • AAP-3.B.4 חילוץ הליכים עשוי להפריד מאפיינים משותפים כדי לגנרלזציה פונקציונליות במקום להכפיל קוד. הדבר מאפשר שימוש חוזר בקוד התוכנה, מה שעוזר בניהול המורכבות.
  • AAP-3.B.5 שימוש בפארמטרים מאפשר גנרליזציה של הליכים, ומאפשר לחזר אותם לשימוש עם מגוון ערכי כניסה או ארגומנטים.
  • AAP-3.B.6 שימוש בחילוץ הליכים עוזר לשפר את קריאות הקוד.
  • AAP-3.B.7 שימוש בחילוץ הליכים בתוכנית מאפשר למפתחים לשנות את הפנימיים של ההליך (כדי להפוך אותו למהיר יותר, יעיל יותר, לצרוך פחות זיכרון וכו') מבלי צורך בהודעת משתמשים על השינוי, כל עוד מה שההליך עושה נשמר.

מטרות לימוד AAP-3.C: פיתוח חילוצי הליכים לניהול מורכבות בתוכנית על ידי כתיבת הליכים. [מיומנות 3.B]

  • AAP-3.C.1 דף העזר לבחן מספק

    טקסט:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> }

    בלוק:

    PROCEDURE procName parameter1, parameter2,... block of statements

    שמשתמש כדי להגדיר הליך לקבל אפס או יותר ארגומנטים. ההליך מכיל block of statements.

  • AAP-3.C.2 דף העזר לבחן מספק

    טקסט:

    PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> RETURN(expression) }

    בלוק:

    PROCEDURE procName parameter1, parameter2,... block of statements RETURN expression

    שמשתמש כדי להגדיר הליך לקבל אפס או יותר ארגומנטים. ההליך מכיל block of statements ומחזיר את הערך של expression. פקודת RETURN עשויה להופיע בכל מקום בתוך ההליך וגורמת לחזרה מיידית מההליך חזרה לפקודה הקוראת.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

You define a procedure with a name, parameters (inputs), and a body, and optionally RETURN a result:

Writing your own procedures reduces repetition, breaks a big problem into named pieces, and makes programs readable and easier to test – the essence of abstraction 抽象.

עברית

את מגדירה פרוצדורה בשם, פרמטרים (כניסות), וגוף, ואופציונלית RETURN תוצאה:

פירוק תוכנה לפרוצדורות ופרוצדורות משנה
פירוק תוכנה לפרוצדורות ופרוצדורות משנה
PROCEDURE Add(a, b)
{
    RETURN(a + b)
}

כתיבת פרוצדורות משלך מפחיתה חזרות, מפרק בעיה גדולה לחלקים קרויים, והופכת את התוכניות לקריאות ולקלות יותר לבדיקה – זהו ליבת ה-ה abstraction.

Vocabulary · ⁨מילון מונחים⁩ Train · ⁨אימון⁩
English עברית
procedure (function)/prəˈsiːdʒə/ פרוצדורה (פונקציה)
procedural abstraction/prəˈsiːdʒərəl əbˈstrækʃn/ הפשטה פרוצדורלית
abstraction/əbˈstrækʃn/ הפשטה
library/ˈlaɪbrəri/ ספרייה
simulation/ˌsɪmjʊˈleɪʃn/ סימולציה
Efficiency/ɪˈfɪʃənsi/ יעילות
heuristic/hjuːˈrɪstɪk/ הוריסטיקה
undecidable/ˌʌndɪˈsaɪdəbl/ בלתי ניתן להחלטה
Interface/ˈɪntəfeɪs/ ממשק
3.14

Libraries · ⁨ספריות⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-3): Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing them to write programs more quickly and with more confidence.

Learning Objective AAP-3.D: Select appropriate libraries or existing code segments to use in creating new programs. [Skill 2.B]

  • AAP-3.D.1 A software library contains procedures that may be used in creating new programs.
  • AAP-3.D.2 Existing code segments can come from internal or external sources, such as libraries or previously written code.
  • AAP-3.D.3 The use of libraries simplifies the task of creating complex programs.
  • AAP-3.D.4 Application program interfaces (APIs) are specifications for how the procedures in a library behave and can be used.
  • AAP-3.D.5 Documentation for an API/library is necessary in understanding the behaviors provided by the API/library and how to use them.
עברית

הבנה מתמשכת (AAP-3): מתכננים מפצלים בעיות לחלקים קטנים ויותר ניתנים לניהול. על ידי יצירת פרוצדורות והיעזרות בפרמטרים, מתכננים ממחישים תהליכים שניתן להשתמש בהם שוב. פרוצדורות מאפשרות למתכננים להתייחס לקוד קיים שנבדק כבר, מה שמאפשר להם לכתוב תוכנות מהר יותר ובביטחון רב יותר.

מטרות לימוד AAP-3.D: בחירת ספריות מתאימות או מקטעי קוד קיימים לשימוש ביצירת תוכניות חדשות. [מיומנות 2.B]

  • AAP-3.D.1 ספריית תוכנה מכילה הליכים שניתן להשתמש בהם ביצירת תוכניות חדשות.
  • AAP-3.D.2 מקטעי קוד קיימים יכולים לבוא ממקורות פנימיים או חיצוניים, כמו ספריות או קוד שנכתב בעבר.
  • AAP-3.D.3 השימוש בספריות מפשט את המשימה של יצירת תוכניות מורכבות.
  • AAP-3.D.4 ממשקי תוכנת אפליקציה (APIs) הם ספקים עבור האופן שבו הליכים בספרייה מתנהגים ועלולים להיות משמשים.
  • AAP-3.D.5 מסמכות ל-API/ספרייה נדרשת בהבנת ההתנהגויות המסופקות על ידי ה-API/ספרייה ובאופן השימוש בהן.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A library 库 is a collection of ready-made procedures that others can reuse. An API (Application Program Interface) 应用程序接口 documents what each procedure does, its parameters, and its result – so you can use it without seeing its code. Libraries save time and let you build on existing, tested work.

The documentation is part of the library. Documentation for an API or library is necessary in order to understand the behaviours it provides and how to use them — what each procedure expects as parameters, what it returns, and what it does at the edges. Without it you would have to read the source, which defeats the point of abstraction; with it you can use a procedure correctly without knowing how it works inside.

עברית

ספרייה היא אוסף של פרוצדורות מוכנות שניתן להשתמש בהן שוב. API (ממשק תכנת אפליקציה) תיעד מה עושה כל פרוצדורה, את הפרמטרים שלה ואת התוצאה שלה – כך שתוכל להשתמש בה מבלי לראות את הקוד שלה. ספריות חוסכות זמן ומאפשרות לך לבנות על עבודה קיימת ובדוקה.

התעודה היא חלק מהספרייה. תיעוד עבור API או ספרייה הוא חיוני כדי להבין את ההתנהגויות שהיא מספקת וכיצד להשתמש בהן — מה כל פרוצדורה מצפה לקבל כפרמטרים, מה היא מחזירה, ומה היא עושה בקצוות. בלעדה היית צריך לקרוא את המקור, מה שמבטל את מטרת הה abstraction; עם התעודה ניתן להשתמש בפרוצדורה בצורה נכונה מבלי לדעת כיצד היא פועלת בפנים.

3.15

Random Values · ⁨ערכים רנדומליים⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-3): Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing them to write programs more quickly and with more confidence.

Learning Objective AAP-3.E: For generating random values: a. Write expressions to generate possible values. [Skill 2.B] b. Evaluate expressions to determine the possible results. [Skill 4.B]

  • AAP-3.E.1 The exam reference sheet provides

    Text:

    RANDOM(a, b)

    Block:

    RANDOM a, b

    which generates and returns a random integer from a to b, inclusive. Each result is equally likely to occur. For example, RANDOM(1, 3) could return 1, 2, or 3.

  • AAP-3.E.2 Using random number generation in a program means each execution may produce a different result.

עברית

הבנה מתמשכת (AAP-3): מתכננים מפצלים בעיות לחלקים קטנים ויותר ניתנים לניהול. על ידי יצירת פרוצדורות והיעזרות בפרמטרים, מתכננים ממחישים תהליכים שניתן להשתמש בהם שוב. פרוצדורות מאפשרות למתכננים להתייחס לקוד קיים שנבדק כבר, מה שמאפשר להם לכתוב תוכנות מהר יותר ובביטחון רב יותר.

מטרות לימוד AAP-3.E: ליצירת ערכים אקראיים: א. כתוב ביטויים ליצירת ערכים אפשריים. [מיומנות 2.B] ב. חשב ביטויים כדי לקבוע תוצאות אפשריות. [מיומנות 4.B]

  • AAP-3.E.1 דף ההפניות לבחינה מספק

    טקסט:

    RANDOM(a, b)

    בלוק:

    RANDOM a, b

שמייצר ומחזיר מספר שלם אקראי בין a ל-b, כולל השניים. לכל תוצאה יש סיכון שווה להתרחשות. לדוגמה, RANDOM(1, 3) עשויה להחזיר 1, 2 או 3.

  • AAP-3.E.2 השימוש בהחזרת מספרים אקראיים בתוכנית פירושה שהכל ביצוע עשוי להניב תוצאה שונה.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

RANDOM(a, b) returns a random integer from a to b (inclusive), letting a program produce unpredictable results – for games, sampling, or simulations. Each call may give a different value, so a program using randomness behaves differently each run.

עברית

RANDOM(a, b) מחזיר מספר שלם רנדומלי מ-a עד b (כולל), ומאפשר לתוכנית לייצר תוצאות בלתי צפויות – למשחקים, דגימה, או סימולציות. כל שיחה עשויה להחזיר ערך שונה, ולכן תוכנית המשתמשת ברנדומליות תתנהג בצורה שונה בכל הפעלה.

3.16

Simulations · ⁨סימולציות⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-3): Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing them to write programs more quickly and with more confidence.

Learning Objective AAP-3.F: For simulations: a. Explain how computers can be used to represent real-world phenomena or outcomes. [Skill 1.A] b. Compare simulations with real-world contexts. [Skill 1.D]

  • AAP-3.F.1 Simulations are abstractions of more complex objects or phenomena for a specific purpose.
  • AAP-3.F.2 A simulation is a representation that uses varying sets of values to reflect the changing state of a phenomenon.
  • AAP-3.F.3 Simulations often mimic real-world events with the purpose of drawing inferences, allowing investigation of a phenomenon without the constraints of the real world.
  • AAP-3.F.4 The process of developing an abstract simulation involves removing specific details or simplifying functionality.
  • AAP-3.F.5 Simulations can contain bias derived from the choices of real-world elements that were included or excluded.
  • AAP-3.F.6 Simulations are most useful when real-world events are impractical for experiments (e.g., too big, too small, too fast, too slow, too expensive, or too dangerous).
  • AAP-3.F.7 Simulations facilitate the formulation and refinement of hypotheses related to the objects or phenomena under consideration.
  • AAP-3.F.8 Random number generators can be used to simulate the variability that exists in the real world.
עברית

הבנה מתמשכת (AAP-3): מתכננים מפצלים בעיות לחלקים קטנים ויותר ניתנים לניהול. על ידי יצירת פרוצדורות והיעזרות בפרמטרים, מתכננים ממחישים תהליכים שניתן להשתמש בהם שוב. פרוצדורות מאפשרות למתכננים להתייחס לקוד קיים שנבדק כבר, מה שמאפשר להם לכתוב תוכנות מהר יותר ובביטחון רב יותר.

מטרות למידה AAP-3.F: עבור סימולציות: א. הסבר כיצד מחשבים יכולים לשמש לייצוג תופעות או תוצאות מהעולם האמיתי. [מיומנות 1.A] ב. השוואת סימולציות עם הקשרים מהעולם האמיתי. [מיומנות 1.D]

  • AAP-3.F.1 סימולציות הן אבסטרקציה של עצמים או תופעות מורכבות יותר לצורך ספציפי.
  • AAP-3.F.2 סימולציה היא ייצוג המשמש מערכי ערכים משתנים כדי לשקף את המצב המתגלגל של תופעה.
  • AAP-3.F.3 סימולציות לעיתים קרובות מדמות אירועים מהעולם האמיתי במטרה להסיק מסקנות, ולאפשר בדיקה של תופעה ללא מגבלות העולם האמיתי.
  • AAP-3.F.4 תהליך פיתוח סימולציה אבסטרקטית כולל הסרת פרטים ספציפיים או הפשטת פונקציונליות.
  • AAP-3.F.5 סימולציות עשויות להכיל שיפוע הנגזר מבחירות של אלמנטים מהעולם האמיתי שנכללו או נשללו.
  • AAP-3.F.6 סימולציות מועילות ביותר כאשר אירועים מהעולם האמיתי אינם מעשיים לניסויים (למשל: גדולים מדי, קטנים מדי, מהירים מדי, איטיים מדי, יקרים מדי או מסוכנים מדי).
  • AAP-3.F.7 סימולציות מקלות על ניסוח ועיבוד של היפותזות הקשורות לעצמים או תופעות הנבדקות.
  • AAP-3.F.8 מחזירי מספרים אקראיים יכולים לשמש לחיקוי השונות הקיימת בעולם האמיתי.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

A simulation 模拟 is a program that models a real-world process to study it safely and cheaply. Simulations simplify reality (they leave out detail) and often use randomness to imitate chance events. They let you test scenarios that would be too costly, slow, or dangerous in real life – but their results are only as good as their assumptions.

A simulation is a way of doing science, not just a picture. Because it can be run many times, cheaply and with one variable changed at a time, a simulation facilitates the formulation and refinement of hypotheses about the object or phenomenon under consideration: you propose an explanation, run the model, compare the result with reality, and adjust either the hypothesis or the model. That is why a simulation's simplifications matter — a result only supports a hypothesis about the real world to the extent that what was left out does not matter.

עברית

סימולציה היא תוכנית שמדמה תהליך בעולם האמיתי כדי ללמוד אותו בבטיחות ובזול. סימולציות מצמיחות את המציאות (הן משאירות פרטים בחוץ) ומשתמשות לעיתים קרובות ברנדומליות כדי לדמות אירועי מקרה. הן מאפשרות לך לבדוק תרחישים שהיו יקרים, איטיים או מסוכנים מדי בעולם האמיתי – אך התוצאות שלהן טובות רק במידה שההנחות עליהן מבוססות מדויקות.

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

3.17

Algorithmic Efficiency · ⁨יעילות אלגוריתמית⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-4): There exist problems that computers cannot solve, and even when a computer can solve a problem, it may not be able to do so in a reasonable amount of time.

Learning Objective AAP-4.A: For determining the efficiency of an algorithm: a. Explain the difference between algorithms that run in reasonable time and those that do not. [Skill 1.D] b. Identify situations where a heuristic solution may be more appropriate. [Skill 1.D]

  • AAP-4.A.1 A problem is a general description of a task that can (or cannot) be solved algorithmically. An instance of a problem also includes specific input. For example, sorting is a problem; sorting the list (2,3,1,7) is an instance of the problem.
  • AAP-4.A.2 A decision problem is a problem with a yes/no answer (e.g., is there a path from A to B?). An optimization problem is a problem with the goal of finding the "best" solution among many (e.g., what is the shortest path from A to B?).
  • AAP-4.A.3 Efficiency is an estimation of the amount of computational resources used by an algorithm. Efficiency is typically expressed as a function of the size of the input.
    • Exclusion statement (EK AAP-4.A.3): Formal analysis of algorithms (Big-O) and formal reasoning using mathematical formulas are outside the scope of this course and the AP Exam.
  • AAP-4.A.4 An algorithm's efficiency is determined through formal or mathematical reasoning.
  • AAP-4.A.5 An algorithm's efficiency can be informally measured by determining the number of times a statement or group of statements executes.
  • AAP-4.A.6 Different correct algorithms for the same problem can have different efficiencies.
  • AAP-4.A.7 Algorithms with a polynomial efficiency or slower (constant, linear, square, cube, etc.) are said to run in a reasonable amount of time. Algorithms with exponential or factorial efficiencies are examples of algorithms that run in an unreasonable amount of time.
  • AAP-4.A.8 Some problems cannot be solved in a reasonable amount of time because there is no efficient algorithm for solving them. In these cases, approximate solutions are sought.
  • AAP-4.A.9 A heuristic is an approach to a problem that produces a solution that is not guaranteed to be optimal but may be used when techniques that are guaranteed to always find an optimal solution are impractical.
    • Exclusion statement (AAP-4.A.9): Specific heuristic solutions are outside the scope of this course and the AP Exam.
עברית

הבנה מתמשכת (AAP-4): קיימות בעיות שאין למחשב פתרון להן, ואף כאשר המחשב יכול לפתור בעיה, ייתכן שלא יוכל לעשות זאת בזמן סביר.

מטרות למידה AAP-4.A: לקביעת יעילותו של אלגוריתם: א. הסבר את ההבדל בין אלגוריתמים הפועלים בזמן סביר לבין אלו שאינם פועלים בזמן סביר. [מיומנות 1.D] ב. זיהוי מקרים שבהם פתרון היקטי (היוריסטי) עשוי להיות מתאים יותר. [מיומנות 1.D]

  • AAP-4.A.1 בעיה היא תיאור כללי של משימה שיכולה (או לא יכולה) להיפתר באמצעות אלגוריתם. דוגמה לבעיה כוללת גם קלט ספציפי. לדוגמה, מיון הוא בעיה; מיון הרשימה (2,3,1,7) הוא דוגמה לבעיה זו.
  • AAP-4.A.2 בעיית החלטה היא בעיה עם תשובה כן/לא (למשל, האם קיים מסלול מ-A ל-B?). בעיית מינון היא בעיה שמטרתה למצוא את הפתרון "הטוב ביותר" מבין אפשרויות רבות (למשל, מהו המסלול הקצר ביותר מ-A ל-B?).
  • AAP-4.A.3 יעילות היא הערכת כמות המשאבים החישוביים הנצרכים על ידי אלגוריתם. יעילות מתבטאת בדרך כלל כפונקציה של גודל הקלט.
    • הצהרת אי-כלליות (EK AAP-4.A3): ניתוח פורמלי של אלגוריתמים (Big-O) והסקה פורמלית באמצעות נוסחאות מתמטיות אינם בתחום הלימודים ובמסלול AP.
  • AAP-4.A.4 יעילותו של אלגוריתם נקבעת באמצעות הסקה פורמלית או מתמטית.
  • AAP-4.A.5 ניתן למדוד יעילות של אלגוריתם באופן לא פורמלי על ידי חישוב מספר הפעמים שבו ביטוי או קבוצת ביטויים מתבצעת.
  • AAP-4.A.6 אלגוריתמים שונים ונכונים עבור אותה בעיה עשויים להציג יעילויות שונות.
  • AAP-4.A.7 אלגוריתמים עם יעילות פולינומית או איטית יותר (קבועה, ליניארית, ריבועית, קובית וכו') נחשבים לפועלים בזמן סביר. אלגוריתמים עם יעילות מעריכית או פאקטוריאלית הם דוגמאות לאלגוריתמים הפועלים בזמן לא סביר.
  • AAP-4.A.8 חלק מהבעיות אינן ניתנות לפתרון בזמן סביר מכיוון שאין להן אלגוריתם יעיל לפתרון. במקרים אלו מחפש פתרונות מקבילים.
  • AAP-4.A.9 היוריסטיקה היא גישה לבעיה המייצרת פתרון שאינו מובטח להיות אופטימלי, אך עשויה לשמש כאשר טכניקות המובטחות למצוא פתרון אופטימלי בכל פעם הן לא מעשיות.
    • הצהרת אי-כלליות (AAP-4.A.9): פתרונות הייוריסטיים ספציפיים אינם בתחום הלימודים ובמסלול AP.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

Efficiency 效率 is how much time (or memory) an algorithm needs as its input grows. A reasonable-time algorithm's work grows like a polynomial of the input size (e.g. linear or quadratic); an unreasonable-time algorithm grows far faster (e.g. doubling with each added item), becoming impractical for large inputs. A faster algorithm can make a previously impossible problem solvable. Sometimes an exact answer takes too long, so a heuristic 启发式 – an approach that finds a good-enough answer quickly – is used instead.

עברית

יעילות היא הכמות של זמן (או זיכרון) שאלגוריתם צריך ככל שהקלט שלו גדל. אלגוריתם זמן סביר מתפתח כמו פולינום בגודל הקלט (למשל, ליניארי או ריבועי); אלגוריתם זמן לא סביר מתפתח הרבה מהר יותר (למשל, הכפלה עם כל פריט נוסף), והופך למעשי לאינסטרקציות גדולות. אלגוריתם מהיר יותר יכול להפוך בעיה שכמעט בלתי פתירה לפתירה. לעיתים תשובה מדויקת לוקחת יותר מדי זמן, ולכן במקום זאת משתמשים בהיוריסטיקה – גישה שמציעה תשובה טובה מספיק במהירות.

איך זמן הריצה של אלגוריתם גדל עם גודל הקלט n
איך זמן הריצה של אלגוריתם גדל עם גודל הקלט n
3.18

Undecidable Problems · ⁨בעיות בלתי פתירות⁩

Syllabus · ⁨סיילבוס⁩
English

Enduring Understanding (AAP-4): There exist problems that computers cannot solve, and even when a computer can solve a problem, it may not be able to do so in a reasonable amount of time.

Learning Objective AAP-4.B: Explain the existence of undecidable problems in computer science. [Skill 1.A]

  • AAP-4.B.1 A decidable problem is a decision problem for which an algorithm can be written to produce a correct output for all inputs (e.g., "Is the number even?").
  • AAP-4.B.2 An undecidable problem is one for which no algorithm can be constructed that is always capable of providing a correct yes-or-no answer.
    • Exclusion statement (EK AAP-4.B.2): Determining whether a given problem is undecidable is outside the scope of this course and the AP Exam.
  • AAP-4.B.3 An undecidable problem may have some instances that have an algorithmic solution, but there is no algorithmic solution that could solve all instances of the problem.
עברית

הבנה מתמשכת (AAP-4): קיימות בעיות שאין למחשב פתרון להן, ואף כאשר המחשב יכול לפתור בעיה, ייתכן שלא יוכל לעשות זאת בזמן סביר.

מטרת הלמידה AAP-4.B: הסבר על קיום של בעיות בלתי פתירות במדעי המחשב. [מיומנות 1.A]

  • AAP-4.B.1 בעיה פתירה היא בעיית החלטה עבורה ניתן לכתוב אלגוריתם המפיק תוצאה נכונה לכל הקלטים (למשל, "האם המספר זוגי?").
  • AAP-4.B.2 בעיה בלתי פתירה היא בעיה עבורה אין אפשרות לבנות אלגוריתם המסוגל לספק תמיד תשובה נכונה כן/לא.
    • הצהרת אי-כלליות (EK AAP-4.B.2): קביעה האם בעיה נתונה היא בלתי פתירה אינה בתחום הלימודים ובמסלול AP.
  • AAP-4.B.3 בעיה בלתי פתירה עשויה להכיל דוגמאות מסוימות הניתנות לפתרון אלגוריתמי, אך אין אלגוריתם שיכול לפתור את כל הדוגמאות של הבעיה.

Source: College Board AP Course and Exam Description · ⁨מקור: תיאור הקורס והמבחן של College Board AP⁩

English

Some problems are undecidable 不可判定: no algorithm can solve every case of them with a correct yes/no answer. This is a fundamental limit of computing – not a matter of needing a faster computer, but a proof that no such algorithm can exist.

Exam skill: be able to determine a code segment's result by tracing it, compare two algorithms' efficiency (reasonable vs unreasonable time), and recognize procedural and data abstraction in a program.

עברית

ישנן בעSome בלתי פתירות: אין אלגוריתם שיכול לפתור כל מקרה מהן עם תשובה נכונה כן/לא. זוהי מגבלה יסודית של חישוב – לא עניין של צורך במחשב מהיר יותר, אלא הוכחה שאין אלגוריתם כזה יכול להתקיים.

מיומנות לבחינה: יכולת לקבוע תוצאה של מקטע קוד על ידי מעקב אחריו, להשוות בין יעילות של שני אלגוריתמים (זמן סביר מול לא סביר), ולהכיר בה abstraction פרוצדורלית ונתונים בתוכנית.

3.18

Exam tips · ⁨טיפים לבחינות⁩

English
  • Know a variable is a named store for a value and trace how assignment updates it step by step.
  • Read the AP pseudocode carefully — a <- expression assigns, and lists are 1-indexed on the exam reference sheet.
  • Distinguish a variable from a list (a collection accessed by index) and use list operations correctly.
  • Evaluate expressions with the right precedence and boolean logic (AND, OR, NOT).
  • Pick clear, meaningful variable names — the written tasks reward readable code.
עברית
  • לדעת שמשתנה הוא אחסון קרוי לערך ולעקוב אחר הקצאה עדכון צעד אחר צעד.
  • קראו את הפסאודוקוד AP בזהירות — a <- expression מבצע הקצאה, ורשימות ממודדות ב-1 בדף ההפניות לבחינה.
  • להבדיל בין משתנה ל-רשימה (אוסף המיוגש באמצעות אינדקס) ולשתמש נכונה בפעולות על רשימות.
  • חשבו ביטויים עם עדיפות נכונה ולוגיקה בוליאנית (AND, OR, NOT).
  • לבחור שמות משתנים ברורים ומובנים — משימות הכתיבה מעודדות כתיבת קוד קריאה.

Interactive lessons on this topic · ⁨שיעורים אינטראקטיביים בנושא זה⁩

Work through it step by step, with instant-check exercises. · ⁨לעבור על הדברים צעד אחר צעד, עם תרגילים לבדיקה מיידית.⁩

Past Papers · ⁨מבחני עבר⁩

More topics in AP Computer Science Principles · ⁨עקרונות מדעי המחשב - AP⁩ · ⁨נושאים נוספים בAP Computer Science Principles · ⁨עקרונות מדעי המחשב - AP⁩⁩

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

IGCSE, A-Level & AP