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 · ⁨영어 내레이션 · 영어 + 중국어 자막 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 Course and Exam Description⁩

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. · ⁨변수는 한 번에 하나의 값을 저장하는 이름이 붙은 상자입니다. 대입(assign) 은 값을 상자에 복사하는 것이며, 다시 대입하면 기존 값이 상각(overwrite) 됩니다.⁩

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
variable/ˈveərɪəbl/ 变量
assignment/əˈsaɪnmənt/ 과제 배정
Data abstraction/ˈdeɪtə əbˈstrækʃn/ 데이터 추상화(Data abstraction)
remainder/rɪˈmeɪndə/ 나머지
3.2

Data Abstraction · ⁨데이터 추상화⁩

Syllabus
Enduring UnderstandingLearning ObjectiveEssential Knowledge

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

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.

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.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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.

한국어

데이터 추상화는 데이터 모음에 단일 이름을 부여함으로써 복잡성을 관리할 수 있게 해줍니다. 예를 들어, 목록을 사용하는 것보다 수십 개의 개별 변수를 사용하는 것이 훨씬 간편합니다. 세부 사항을 숨겨줍니다: 이름이 붙은 collection을 사용할 때 그 안에 어떻게 저장되어 있는지 걱정할 필요가 없습니다. 아래에 나열된 목록(lists)은 해당 과정의 주요 데이터 추상화 수단입니다.

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
list/lɪst/ 리스트(list)
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 시각적 및 텍스트 기반 프로그래밍 언어 외에도, 자연어, 도표, 가짜 코드(pseudocode) 등 다양한 방식으로 알고리즘을 표현할 수 있다.
  • AAP-2.A.3 프로그램에 의해 실행되는 알고리즘은 프로그래밍 언어를 통해 구현된다.
  • AAP-2.A.4 모든 알고리즘은 순서, 선택, 반복의 조합으로 구성될 수 있다.

학습 목표 AAP-2.B: 순차적 코드 문장을 사용하여 단계별 알고리즘 과정을 나타내기. [기술 2.B]

  • AAP-2.B.1 *순서(Sequencing)*는 코드 문장이 주어진 순서에 따라 알고리즘의 각 단계를 적용하는 것이다.
  • AAP-2.B.2 *코드 문장(code statement)*은 수행해야 할 행동을 나타내는 프로그램 코드의 일부이다.
  • AAP-2.B.3 *수식(expression)*은 값, 변수, 연산자 또는 값을 반환하는 절차 호출로 구성될 수 있다.
  • AAP-2.B.4 수식은 평가되어 단일 값을 산출한다.
  • AAP-2.B.5 수식의 평가는 프로그래밍 언어에서 정의된 연산자 우선순위 규칙에 따른다.
  • AAP-2.B.6 순차 문장은 코드 섹션에 나타나는 순서에 따라 실행된다.
  • AAP-2.B.7 프로그래밍 언어로 알고리즘을 표현할 때 명확성과 가독성은 중요한 고려 사항이다.

학습 목표 AAP-2.C: 산술 연산자를 사용하는 수식을 평가하기. [기술 4.B]

  • AAP-2.C.1 산술 연산자는 대부분의 프로그래밍 언어에 포함되며, 덧셈, 뺄셈, 곱셈, 나눗셈, 나머지(modulus) 연산자가 포함된다.

  • 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

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

  • AAP-2.C.4 수학에서 사용되는 연산자 우선순위는 수식을 평가할 때 적용된다. MOD 연산자는 *과 / 연산자와 동일한 우선순위를 가진다.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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. · ⁨수식은 연산 순서(order of operations) 에 따라 평가됩니다: 곱셈과 나눗셈은 덧셈과 뺄셈보다 먼저 이루어지며, 왼쪽에서 오른쪽으로 진행됩니다.⁩

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 *하위 문자열(substring)*은 기존 문자열의 일부이다.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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.

한국어

문자열(string) 은 "hello"와 같은 순서 있는 문자의 서열입니다. 프로그램은 문자열을 연결(연결)하고 길이를 찾습니다. 문자열은 텍스트(이름, 메시지, 서열 등)를 표현하며, 일반적인 프로그램 입력 및 출력입니다.

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
string/strɪŋ/ 문자열(string)
concatenation/kənˌkætəˈneɪʃn/ 연결 concat
3.5

Boolean Expressions · ⁨부울린 식⁩

Syllabus
Enduring UnderstandingLearning ObjectiveEssential Knowledge

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.

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.

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.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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.

한국어

부울表达式(Boolean expression) 은 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. · ⁨부울Boolean 수식은 참(true, 1) 또는 거짓(false, 0)입니다. OR 연산은 입력 중 적어도 하나가 참일 때 참입니다. 모든 경우를 보기 위해 입력을 바꿔보십시오.⁩

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
Boolean expression/ˈbuːlɪən ekˈspreʃn/ 부울 부호 표현식
conditional (selection)/kənˈdɪʃənl/ 조건부 (선택)
nested conditional/ˈnestɪd kənˈdɪʃənl/ 중첩 조건문(nested conditional)
Iteration (a loop)/ˌɪtəˈreɪʃn/ 반복 (루프)
infinite loop/ˈɪnfɪnət luːp/ 무한 루프(infinite loop)
algorithm/ˈælɡərɪθəm/ 알고리즘
3.6

Conditionals · ⁨조건문⁩

Syllabus
Enduring UnderstandingLearning ObjectiveEssential Knowledge

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.

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.

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.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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. · ⁨조건문(conditional) 은 조건이 참일 때 특정 브랜치를 실행하고, 거짓일 때 다른 브랜치를 실행합니다. 값을 임계점을 넘게 이동하여 어떤 브랜치가 선택되는지 확인하세요.⁩

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: 중첩 선택에 대해: a. 중첩 조건문을 작성하기. [기술 2.B] b. 중첩 조건문의 결과를 판단하기. [기술 4.B]

  • AAP-2.I.1 중첩 조건문은 조건문 안에 다른 조건문이 포함된 구조입니다.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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을 체인)하여 두 개 이상의 path 중 하나를 선택합니다. 첫 번째로 일치하는 분기만 실행됩니다:

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

Iteration · ⁨반복⁩

Syllabus
Enduring UnderstandingLearning ObjectiveEssential Knowledge

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.

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.

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.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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) 루프는 본체 실행 전에 조건을 검사하므로 0회 실행될 수 있음
전제조건(WHILE) 루프는 본체 실행 전에 조건을 검사하므로 0회 실행될 수 있음
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. · ⁨루프(loop) 는 카운터가 범위를遍历할 동안 블록을 반복합니다. 한 번의 반복마다 카운터와 누적 합이 업데이트되는 과정을 단계별로 확인하십시오.⁩

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: 알고리즘에 대해: a. 알고리즘을 생성하기. [기술 2.A] b. 기존 알고리즘을 결합하고 수정하기. [기술 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 Course and Exam Description⁩

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
Enduring UnderstandingLearning ObjectiveEssential Knowledge

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.

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.

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.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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:

한국어

목록(list) 은 하나의 이름 아래 정렬된 값들의 모음으로, 이 과정의 핵심 데이터 추상화 개념입니다. 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: 이진 탐색 알고리즘에 대해: a. 데이터셋에서 값을 찾기所需的 iteration 횟수를 결정함. [스킬 1.D] b. 이진 탐사를 완료하기 위해 필요한 조건을 설명함. [스킬 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 Course and Exam Description⁩

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.

한국어
전화번호부: 이진 탐색은 매 단계마다 남은 페이지 수를 절반으로 줄입니다
전화번호부: 이진 탐색은 각 단계마다 남은 페이지를 절반으로 줄입니다

이진 탐색(binary search) 은 정렬된 목록에서 값을 찾을 때 각 요소를 하나씩 확인하는 것보다 훨씬 빠릅니다. 중앙 요소를 확인한 후 목표가 포함될 수 없는 절반을 제거하고, 찾아질 때까지 반복합니다. 각 단계마다 탐색 범위가 절반으로 줄어들므로, $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): 프로그래머는 문제를 더 작고 관리 가능한 부분으로 분해합니다. procedures를 생성하고 매개변수를 활용함으로써 프로그래머들은 재사용 가능한 프로세스를 일반화합니다. procedures는 이미 테스트된 기존 코드를 활용할 수 있게 하여, 프로그래머들이 더 빠르고 자신감 있게 프로그램을 작성할 수 있게 합니다.

학습 목표 AAP-3.A: procedure 호출에 대해: a. procedure를 호출하는 문장을 작성하십시오. [기술 3.B] b. procedure 호출의 결과 또는 효과를 판단하십시오. [기술 4.B]

  • AAP-3.A.1 procedure는 매개변수와 반환 값을 가질 수 있는 이름이 붙은 프로그래밍 명령의 그룹입니다.

  • AAP-3.A.2 procedure는 프로그래밍 언어에 따라 method 또는 function과 같은 다른 이름으로 불립니다.

  • AAP-3.A.3 *매개변수(Parameters)*는 procedure의 입력 변수입니다. *인자(Arguments)*는 procedure가 호출될 때 매개변수의 값을 지정합니다.

  • AAP-3.A.4 procedure 호출은 문장의 순차적 실행을 중단하여, 프로그램이 procedure 내부의 문장을 먼저 실행한 후 계속하도록 만듭니다. procedure의 마지막 문장(또는 return 문)이 실행되면 제어가 procedure가 호출되었던 지점 바로 뒤로 돌아갑니다.

  • AAP-3.A.5 시험 참고 시트에는

    procName(arg1, arg2, ...)

    이 procedure를 호출하는 방법으로 제공됩니다.

    텍스트:

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

블록:

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

이 procedure는 0개 이상의 인자를 받으며, arg1은 parameter1에 할당되고, arg2은 parameter2에 할당되며, 이와 같이 이어집니다.

  • AAP-3.A.6 시험 참고 시트에는 procedure

    텍스트:

    DISPLAY(expression)

블록:

DISPLAY expression

를 제공하여 expression의 값을 출력한 후 공백을 추가합니다.

  • AAP-3.A.7 시험 참고 시트에는

    텍스트:

    RETURN(expression)

블록:

RETURN expression

문장이 제공되어, 제어를 procedure가 호출되었던 지점으로 되돌리고 expression의 값을 반환하는 데 사용됩니다.

  • AAP-3.A.8 시험 참고 시트에는

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

    을 제공하여 procedure를 호출하여 반환되는 "procedure의 값"을 result에 할당합니다.

    텍스트:

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

블록:

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

  • AAP-3.A.9 시험 참고 시트에는 procedure

    텍스트:

    INPUT()

블록:

INPUT

를 제공하여 사용자로부터 값을 받아입력값을 반환합니다.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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 过程抽象.

한국어

절차(function) 는 이름이 붙고 재사용 가능한 코드 블록입니다. 호唤(calling) 하면 제공한 인자(arguments) 로 해당 코드를 실행하며, 返回值(return) 할 수도 있습니다:

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

절차는 내부 작동 원리를 알지 않고 코드를 사용할 수 있게 해줍니다 — 이것이 절차 추상화(procedural abstraction) 입니다.

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
procedural abstraction/prəˈsiːdʒərəl əbˈstrækʃn/ 절차 추상화
abstraction/əbˈstrækʃn/ 추상화
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): 프로그래머는 문제를 더 작고 관리 가능한 부분으로 분해합니다. procedures를 생성하고 매개변수를 활용함으로써 프로그래머들은 재사용 가능한 프로세스를 일반화합니다. procedures는 이미 테스트된 기존 코드를 활용할 수 있게 하여, 프로그래머들이 더 빠르고 자신감 있게 프로그램을 작성할 수 있게 합니다.

학습 목표 AAP-3.B: procedural abstraction의 사용이程序中의 복잡성을 어떻게 관리하는지 설명하십시오. [기술 3.C]

  • AAP-3.B.1 일반적인 추상의 일종인 procedural abstraction은 프로세스에 이름을 부여하고, procedure가 무엇을 하는지는 알지만 어떻게 수행하는지는 알지 않고도 procedure를 사용할 수 있게 합니다.
  • AAP-3.B.2 procedural abstraction은 큰 문제의 해결책을 작은 하위 문제의 해결책에 기반하게 합니다. 이는 각 하위 문제를 해결하기 위한 procedure를 생성함으로써 달성됩니다.
  • AAP-3.B.3 컴퓨터 프로그램을 별도의 하위 프로그램으로 세분화하는 것을 *모듈성(modularity)*이라고 합니다.
  • AAP-3.B.4 procedural abstraction은 코드를 복사하지 않고 공통된 기능을 추출하여 기능 generalize를 통해 프로그램 코드 재사용을 가능하게 하며, 이는 복잡성 관리를 돕습니다.
  • AAP-3.B.5 매개변수를 사용하면 procedure를 generalize할 수 있어 다양한 입력 값이나 인자를 사용하여 procedure를 재사용할 수 있습니다.
  • AAP-3.B.6 procedural abstraction의 사용은 코드 가독성을 향상시킵니다.
  • AAP-3.B.7程序中에서 procedural abstraction을 사용하면 procedure가 하는 일이 유지되는 한, procedure의 내부 구조(더 빠르게, 효율적으로, 더 적은 저장 공간 사용 등)를 변경해도 사용자에게 변경 사항을 통보할 필요가 없습니다.

학습 목표 AAP-3.C: procedure를 작성하여程序的의 복잡성을 관리하는 procedural abstraction을 개발하십시오. [기술 3.B]

  • AAP-3.C.1 시험 참고 시트에는

    텍스트:

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

블록:

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

을 제공하여 0개 이상의 인자를 받는 procedure를 정의하는 데 사용합니다. procedure에는 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

을 제공하여 0개 이상의 인자를 받는 procedure를 정의하는 데 사용합니다. procedure에는 block of statements이 포함되고 expression의 값을 반환합니다. RETURN 문은 procedure 내부의 어디든 나타날 수 있으며, procedure에서 즉시 호출문으로 되돌아가게 합니다.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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 抽象.

한국어

절차를 정의(define) 할 때는 이름, 파라미터(입력), 본문(body)을 지정하며, 선택적으로 RETURN 결과를 반환할 수 있습니다:

프로그램을 프로시저 및 서브프로시저로 분해하는 모습
프로그램을 절차와 하위 절차로 분해하는 모습
PROCEDURE Add(a, b)
{
    RETURN(a + b)
}

직접 절차를 작성하면 중복을 줄이고 큰 문제를 이름이 붙은 조각들로 나누어 프로그램이 가독성이 높아지고 테스트하기 쉬워집니다 — 이것이 추상化(abstraction) 의 핵심입니다.

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
procedure (function)/prəˈsiːdʒə/ 절차 (함수)
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): 프로그래머는 문제를 더 작고 관리 가능한 부분으로 분해합니다. procedures를 생성하고 매개변수를 활용함으로써 프로그래머들은 재사용 가능한 프로세스를 일반화합니다. procedures는 이미 테스트된 기존 코드를 활용할 수 있게 하여, 프로그래머들이 더 빠르고 자신감 있게 프로그램을 작성할 수 있게 합니다.

학습 목표 AAP-3.D: 새로운 프로그램을 만들 때 사용할 적절한 라이브러리 또는 기존 코드 조각을 선택하십시오. [기술 2.B]

  • AAP-3.D.1 소프트웨어 라이브러리는 새로운 프로그램을 만드는 데 사용할 수 있는 procedure를 포함합니다.
  • AAP-3.D.2 기존 코드 조각은 라이브러리나 이전에 작성한 코드와 같은 내부 또는 외부 소스에서 올 수 있습니다.
  • AAP-3.D.3 라이브리리의 사용은 복잡한 프로그램을 만드는 작업을 간소화합니다.
  • AAP-3.D.4 애플리케이션 프로그래밍 인터페이스(API)는 라이브리리에 있는 procedure의 동작 방식과 사용 방법을 규정한 사양입니다.
  • AAP-3.D.5 API/라이브리리의 문서는 API/라이브리리가 제공하는 동작과使用方法를 이해하는 데 필수적입니다.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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.

한국어

라이브러리(library) 는 다른 사람이 재사용할 수 있는 미리 만든 절차들의 모음입니다. API(응용 프로그램 인터페이스)는 각 절차가 하는 일, 파라미터,返回值를 문서화하여 코드를 보지 않고도 사용할 수 있게 합니다. 라이브러리는 시간을 아끼고 기존에 검증된 작업 위에 빌드할 수 있게 합니다.

문서는 라이브러리의 일부입니다. API나 라이브러리에 대한 문서는 제공하는 기능과 사용 방법을 이해하기 위해 필수적입니다 — 각 절차가需要什么作为参数, 返回什么, 그리고 가장자리 조건에서 무엇을 하는지 등입니다. 문서가 없으면 소스 코드를 읽어야 하므로 추상화의 의미가 사라지며, 문서가 있으면 내부 작동 원리를 몰라도 올바르게 절차를 사용할 수 있습니다.

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
library/ˈlaɪbrəri/ 라이브러리(library)
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): 프로그래머는 문제를 더 작고 관리 가능한 부분으로 분해합니다. procedures를 생성하고 매개변수를 활용함으로써 프로그래머들은 재사용 가능한 프로세스를 일반화합니다. procedures는 이미 테스트된 기존 코드를 활용할 수 있게 하여, 프로그래머들이 더 빠르고 자신감 있게 프로그램을 작성할 수 있게 합니다.

학습 목표 AAP-3.E: 무작위 값 생성에 대해: a. 가능한 값을 생성하는 표현을 작성하십시오. [기술 2.B] 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 Course and Exam Description⁩

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): 프로그래머는 문제를 더 작고 관리 가능한 부분으로 분해합니다. procedures를 생성하고 매개변수를 활용함으로써 프로그래머들은 재사용 가능한 프로세스를 일반화합니다. procedures는 이미 테스트된 기존 코드를 활용할 수 있게 하여, 프로그래머들이 더 빠르고 자신감 있게 프로그램을 작성할 수 있게 합니다.

학습 목표 AAP-3.F: 시뮬레이션에 대해: a. 컴퓨터가 실제 세계의 현상이나 결과를 어떻게 표현하는지 설명하십시오. [기술 1.A] b. 시뮬레이션과 실제 세계의 맥락을 비교하십시오. [기술 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 Course and Exam Description⁩

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.

한국어

시뮬레이션(simulation) 은 실제 세계 과정을 모델링하여 안전하고 저렴하게 연구하는 프로그램입니다. 시뮬레이션은 현실을 간소화(simplify) (세부 사항을 생략함)하며, 종종 우연한 사건을 모사하기 위해 무작위성(randomness) 을 사용합니다. 실제로는 비용이 너무 많이 들거나 느리거나 위험할 scenarios를 테스트할 수 있게 해주지만, 그 결과는 가정의 정확도에 의존합니다.

**시뮬레이션은 단순한 그림이 아니라 과학을 수행하는 방법입니다.**cheaply且多次运行,且每次只改变一个变量,因此模拟有助于对研究对象或现象提出和修正假设:你提出一种解释,运行模型,将结果与现实比较,然后调整假设或模型。这就是为什么模拟的简化很重要——只有当被省略的部分无关紧要时,结果才能支持关于现实世界的假设。

Vocabulary · ⁨어휘⁩ Train · ⁨연습하기⁩
English 한국어
simulation/ˌsɪmjʊˈleɪʃn/ 시뮬레이션(simulation)
Efficiency/ɪˈfɪʃənsi/ 효율성
heuristic/hjuːˈrɪstɪk/ 히어리스틱
undecidable/ˌʌndɪˈsaɪdəbl/ 해결 불가능함
Interface/ˈɪntəfeɪs/ 인터페이스
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): 컴퓨터가 해결할 수 없는 문제가 존재하며,even computer가 문제를 해결할 수 있더라도 합리적인 시간 내에 해결하지 못할 수 있습니다.

학습 목표 AAP-4.A: 알고리즘의 효율성을 결정하기 위해: a. 합리적인 시간에 실행되는 알고리즘과 그렇지 않은 알고리즘의 차이를 설명하십시오. [기술 1.D] b. 히어리스틱 해법이 더 적절한 상황 식별. [기술 1.D]

  • AAP-4.A.1 문제는 알고리즘적으로 (또는 할 수 없음) 해결될 수 있는 작업의 일반적인 설명입니다. 문제의 인스턴스도 구체적인 입력을 포함합니다. 예를 들어, 정렬은一个问题; 목록 (2,3,1,7)을 정렬하는 것은 해당 문제의 인스턴스입니다.
  • AAP-4.A.2 결정 문제는 예/아니오 답을 가진 문제입니다(예: A에서 B까지 경로가 있는가?). 최적화 문제는 여러 solution 중 "최선"을 찾는 것을 목표로 하는 문제입니다(예: A에서 B까지 최단 경로는 무엇인가?).
  • AAP-4.A.3 효율성은 알고리즘이 사용하는 컴퓨팅 자원의 양을 추정하는 것입니다. 효율성은 일반적으로 입력 크기의 함수로 표현됩니다.
    • 배제 문항(EK AAP-4.A.3): 알고리즘의 형식적 분석(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 히어리스틱은 항상 최적해임을 보장하지는 않지만, 항상 최적해를 찾는 technique이 비현실적인 경우에 사용할 수 있는 문제 접근 방식입니다.
    • 배제 문항(AAP-4.A.9): 구체적인 히어리스틱 해법은 이 과정 및 AP 시험의 범위를 벗어납니다.

Source: College Board AP Course and Exam Description · ⁨출처: College Board AP Course and Exam Description⁩

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): 컴퓨터가 해결할 수 없는 문제가 존재하며,even computer가 문제를 해결할 수 있더라도 합리적인 시간 내에 해결하지 못할 수 있습니다.

학습 목표 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 Course and Exam Description⁩

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.

한국어

일부 문제는 결정 불가능합니다: 모든 경우에서 올바른 예/아니오 답을 제공하며 이를 해결할 수 있는 알고리즘은 존재하지 않습니다. 이는更快地计算机가 필요하다는 문제가 아니라 그러한 알고리즘이 존재할 수 없음을 증명하는 것인 컴퓨팅의 근본적인 한계입니다.

시험 대비 기술: 코드 세그먼트의 결과를 추적하여 판단하고, 두 알고리즘의 효율성(적절한 시간 vs 부적절한 시간)을 비교하며, 프로그램 내 절차 추상화 및 데이터 추상화를 식별할 수 있어야 합니다.

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는 대입을 수행하며, Exam Reference Sheet에서는 리스트가 1부터 시작합니다.
  • 변수와 리스트(인덱스로 액세스하는 집합)를 구분하고, 리스트 연산을 올바르게 사용하세요.
  • 옳은 precedence와 부울 논리를 사용하여 식을 평가하세요 (AND, OR, NOT).
  • 명확하고 의미 있는 변수 이름을 선택하세요 — 서면 과제는 가독성이 높은 코드를reward합니다.

Interactive lessons on this topic · ⁨이 주제에 대한 인터랙티브 수업⁩

Work through it step by step, with instant-check exercises. · ⁨즉시 체크 기능 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