AP CSA
离开考还有:
A message for my AP Computer Science class
写给我的 AP 计算机科学班的一封信
I know some of you walk into this class wondering: What is this class really about? Can I succeed? What happens if I mess up?
我知道有些同学刚开始可能会想:这门课到底学什么?我能不能学会?要是我搞砸了怎么办?
So let me be upfront and tell you what you can expect from me — and from yourself — in this class.
所以我想一开始就告诉你:在这门课上,你可以对我、对自己有什么期待。
1. What is it like to learn in this class?
1. 在这门课上学习是种什么体验?
Learning something new — especially computer science — isn’t supposed to be easy at first.
学习新东西,特别是计算机科学,一开始本来就不会轻松。
You might feel frustrated or confused. That’s normal.
你可能会感到挫败或困惑,这是正常的。
In this class, we don’t aim for instant 100s. We aim for growth.
在这门课上,我们不是追求立刻拿满分,而是追求成长。
If you put in the effort, things that once felt impossible will start to feel manageable.
只要你努力,原本觉得很难的事情会慢慢变得可以做到。
I’ve seen it happen over and over again.
我已经见过很多次学生从不会到会的过程。
2. What does it mean if I struggle?
2. 如果我学得很吃力,是不是就代表我不行?
Struggle isn’t a failure. It’s a signal — it means you’re trying something challenging and important.
“吃力”不代表失败,而是一种信号,说明你正在努力尝试有挑战性的东西。
Mistakes will happen, and we’ll treat those mistakes as learning tools, not as flaws.
犯错是常事,我们会把错误当作学习的工具,而不是缺点。
When you stumble, it helps me teach better — and it helps us all learn more together.
你在学习中跌倒,能帮我更好地指导,也让我们大家一起学得更深。
3. Can I ask questions?
3. 我可以随时提问吗?
Always. Your questions are welcome — even if they feel “basic.”
当然可以。你的问题总是被欢迎的——哪怕看起来很“基础”。
Asking is a sign of strength, not weakness.
提问是勇气的表现,不是软弱。
In fact, if you have a question, chances are that half the class is wondering the same thing.
其实你问的问题,往往也是班上一半同学的疑问。
I’ll always praise thoughtful questions because they make all of us better.
我会一直鼓励有思考的问题,因为它们能让我们大家都进步。
4. Why do we revise so much?
4. 为什么我们要经常复习?
You’ll often revisit past work — not as a punishment, but because revising is how real learning happens.
我们会多次回头看旧作业,不是惩罚,而是因为真正的学习就是在“修正”中发生的。
Debugging, fixing, and improving are part of the coding process and the thinking process.
调试、修改和改进是编程的自然过程,也是真正思考的一部分。
The goal isn’t just to “finish” something — it’s to understand it deeply.
我们的目标不是“做完”一件事,而是真正理解它。
5. What does a score mean in this class?
5. 分数在这门课上代表什么?
Scores are snapshots, not verdicts.
分数只是某一刻的“快照”,不是你的“判决”。
A number can’t capture your potential, your growth, or your future.
一个数字无法代表你的潜力、成长或未来。
My job isn’t to label you — it’s to help you become a confident, capable thinker.
我的责任不是给你贴标签,而是帮助你成为一个有信心、有能力的思考者。
You are more than a grade.
你远远不只是一个分数。
🧠 I’ll remind you of these principles throughout the year — especially during tough moments.
🧠 这一整年,我都会反复提醒你这些理念——特别是在你觉得困难的时候。
If you’re putting in the effort, I will always support you.
只要你在努力,我永远会支持你。
My job is to give you the tools, feedback, and belief you need to succeed.
我的任务是提供你成功所需要的工具、反馈和信心。
Let’s build something great together.
— Mr. Mou
- Java Style Guidelines
- 必考 Array 算法
Array Algorithms with Different Loop Versions
1. Determine the Minimum or Maximum Value in an Array
Find Maximum Value
import java.util.Arrays;
public class ArrayAlgorithms {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
// Using for loop
int max = numbers[0];
for (int i = 1; i < numbers.length; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
}
System.out.println("Max value (for loop): " + max);
// Using enhanced for loop
max = numbers[0];
for (int num : numbers) {
if (num > max) {
max = num;
}
}
System.out.println("Max value (enhanced for loop): " + max);
}
}
2. Compute a Sum or Average of Array Elements
Compute Sum
public class ArraySum {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
// Using for loop
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
System.out.println("Sum (for loop): " + sum);
// Using enhanced for loop
sum = 0;
for (int num : numbers) {
sum += num;
}
System.out.println("Sum (enhanced for loop): " + sum);
}
}
Compute Average
public class ArrayAverage {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
int sum = 0;
// Using for loop to compute sum
for (int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
System.out.println("Sum (for loop): " + sum);
// Compute average
double average = (double) sum / numbers.length;
System.out.println("Average: " + average);
}
}
3. Search for a Particular Element in the Array
Search for the Number 7
public class ArraySearch {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
int target = 7;
boolean found = false;
// Using for loop
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] == target) {
found = true;
break;
}
}
System.out.println("Found (for loop): " + found);
// Using enhanced for loop
found = false;
for (int num : numbers) {
if (num == target) {
found = true;
break;
}
}
System.out.println("Found (enhanced for loop): " + found);
}
}
4. Determine if At Least One Element Has a Particular Property
Check if at Least One Element is Even
public class ArrayProperty {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
boolean hasEven = false;
// Using for loop
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] % 2 == 0) {
hasEven = true;
break;
}
}
System.out.println("Has even (for loop): " + hasEven);
// Using enhanced for loop
hasEven = false;
for (int num : numbers) {
if (num % 2 == 0) {
hasEven = true;
break;
}
}
System.out.println("Has even (enhanced for loop): " + hasEven);
}
}
5. Determine if All Elements Have a Particular Property
Check if All Elements are Positive
public class ArrayAllPositive {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
boolean allPositive = true;
// Using for loop
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] <= 0) {
allPositive = false;
break;
}
}
System.out.println("All positive (for loop): " + allPositive);
// Using enhanced for loop
allPositive = true;
for (int num : numbers) {
if (num <= 0) {
allPositive = false;
break;
}
}
System.out.println("All positive (enhanced for loop): " + allPositive);
}
}
6. Access All Consecutive Pairs of Elements
public class ConsecutivePairs {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
// Using for loop
for (int i = 0; i < numbers.length - 1; i++) {
System.out.println("Pair: " + numbers[i] + ", " + numbers[i + 1]);
}
// Enhanced for loop is not ideal for this task because it does not provide access to indices.
}
}
7. Determine the Presence or Absence of Duplicate Elements
public class DuplicateCheck {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
boolean hasDuplicate = false;
// Using for loop
for (int i = 0; i < numbers.length; i++) {
for (int j = i + 1; j < numbers.length; j++) {
if (numbers[i] == numbers[j]) {
hasDuplicate = true;
break;
}
}
if (hasDuplicate) break;
}
System.out.println("Has duplicate (for loop): " + hasDuplicate);
// Enhanced for loop is not ideal for this task due to the need for two indices.
}
}
8. Determine the Number of Elements Meeting Specific Criteria
Count Odd Numbers
public class CountOddNumbers {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
int oddCount = 0;
// Using for loop
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] % 2 != 0) {
oddCount++;
}
}
System.out.println("Odd count (for loop): " + oddCount);
// Using enhanced for loop
oddCount = 0;
for (int num : numbers) {
if (num % 2 != 0) {
oddCount++;
}
}
System.out.println("Odd count (enhanced for loop): " + oddCount);
}
}
9. Shift or Rotate Elements Left or Right
Shift Elements Left by One Position
import java.util.Arrays;
public class ShiftLeft {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
// Using for loop
int first = numbers[0];
for (int i = 0; i < numbers.length - 1; i++) {
numbers[i] = numbers[i + 1];
}
numbers[numbers.length - 1] = first;
System.out.println("Shifted left (for loop): " + Arrays.toString(numbers));
}
}
Shift Elements Right by One Position
import java.util.Arrays;
public class ShiftRight {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
// Save the last element since it will wrap around to the front
int last = numbers[numbers.length - 1];
// Shift each element to the right by 1 position
for (int i = numbers.length - 1; i > 0; i--) {
numbers[i] = numbers[i - 1];
}
// Place the last element in the first position
numbers[0] = last;
System.out.println("Shifted right by 1: " + Arrays.toString(numbers));
}
}
10. Reverse the Order of the Elements
1. Using a Two-Pointer Technique
import java.util.Arrays;
public class ReverseArray {
public static void main(String[] args) {
int[] numbers = {3, 5, 1, 7, 9};
for (int i = 0; i < numbers.length / 2; i++) {
int temp = numbers[i];
numbers[i] = numbers[numbers.length - 1 - i];
numbers[numbers.length - 1 - i] = temp;
}
System.out.println("Reversed (for loop): " + Arrays.toString(numbers));
}
}
2. Using an Auxiliary Array
import java.util.Arrays;
public class ReverseArray {
public static void main(String[] args) {
int[] numbers2 = {3, 5, 1, 7};
// Create a new array
int[] reversed = new int[numbers2.length];
for (int i = 0; i < numbers2.length; i++) {
reversed[i] = numbers2[numbers2.length - 1 - i];
}
System.out.println("Reversed array: " + Arrays.toString(reversed));
}
}
AP CSA Sorting Algorithms (AP CSA 排序算法)
1. Merge Sort (归并排序)
Merge Sort Implementation (归并排序实现)
import java.util.Arrays;
public class MergeSortAPCSA {
// Public method to start the merge sort process
// 公共方法,开始归并排序
public static void mergeSort(int[] arr) {
if (arr.length <= 1) {
return; // Base case: A single-element array is already sorted
// 基本情况:单元素数组已经是有序的
}
// Step 1: Create a temporary array for merging
// 第一步:创建一个临时数组用于归并
int[] temp = new int[arr.length];
// Step 2: Call the recursive helper method to perform merge sort
// 第二步:调用递归辅助方法执行归并排序
mergeSortHelper(arr, 0, arr.length - 1, temp);
}
// Recursive helper method that splits the array into smaller subarrays
// 递归辅助方法,将数组拆分成更小的子数组
private static void mergeSortHelper(int[] arr, int left, int right, int[] temp) {
if (left < right) { // Base case: If left == right, there's only one element, so stop.
// 基本情况:如果 left == right,说明只有一个元素,无需继续
int mid = (left + right) / 2; // Find the middle index
// 找到中间索引
// Recursively sort the left half of the array
// 递归排序左半部分
mergeSortHelper(arr, left, mid, temp);
// Recursively sort the right half of the array
// 递归排序右半部分
mergeSortHelper(arr, mid + 1, right, temp);
// Merge the two sorted halves
// 归并两个已排序的部分
merge(arr, left, mid, right, temp);
}
}
// Merges two sorted halves of the array into a single sorted section
// 归并两个已排序的部分,使其成为一个有序部分
private static void merge(int[] arr, int left, int mid, int right, int[] temp) {
int i = left, j = mid + 1, k = left;
// i 指向左半部分的起始位置 (left)
// j 指向右半部分的起始位置 (mid + 1)
// k 指向临时数组 temp 的起始位置 (left)
// Step 1: Compare elements from both halves and place the smaller one in temp[]
// 第一步:比较左右两部分的元素,把较小的元素放入 temp[]
while (i <= mid && j <= right) {
if (arr[i] < arr[j]) {
temp[k] = arr[i++];
} else {
temp[k] = arr[j++];
}
k++;
}
// Step 2: Copy remaining elements from the left half
// 第二步:复制左半部分的剩余元素
while (i <= mid) {
temp[k++] = arr[i++];
}
// Step 3: Copy remaining elements from the right half
// 第三步:复制右半部分的剩余元素
while (j <= right) {
temp[k++] = arr[j++];
}
// Step 4: Copy sorted elements from temp[] back into the original array
// 第四步:将 temp[] 中的有序元素复制回原数组
for (k = left; k <= right; k++) {
arr[k] = temp[k];
}
}
// Main method to test Merge Sort
// 主方法,用于测试归并排序
public static void main(String[] args) {
int[] arr = {7, 2, 5, 3}; // Example array
// 示例数组
System.out.println("Before sorting: " + Arrays.toString(arr));
mergeSort(arr);
System.out.println("After sorting: " + Arrays.toString(arr));
}
}
2. Selection Sort (选择排序)
Selection Sort Implementation (选择排序实现)
import java.util.Arrays;
public class SortTest {
public static void selectionSort(int[] arr) {
// Iterate through each element of the array
// 遍历数组中的每个元素
for (int i = 0; i < arr.length - 1; i++) {
int minIndex = i; // Assume the first unsorted element is the smallest
// 假设第一个未排序的元素是最小的
// Find the index of the smallest element in the unsorted part
// 在未排序部分中找到最小元素的索引
for (int j = i + 1; j < arr.length; j++) {
if (arr[j] < arr[minIndex]) {
minIndex = j; // Update minIndex if a smaller element is found
// 如果找到更小的元素,则更新 minIndex
}
}
// Swap the smallest element found with the first unsorted element
// 交换找到的最小元素与当前未排序部分的第一个元素
int temp = arr[minIndex];
arr[minIndex] = arr[i];
arr[i] = temp;
}
}
public static void main(String[] args) {
int[] arr1 = {3, 86, -20, 14, 40}; // Example array
System.out.println("Before sorting: " + Arrays.toString(arr1));
selectionSort(arr1);
System.out.println("After sorting: " + Arrays.toString(arr1));
}
}
3. Insertion Sort (插入排序)
Insertion Sort Implementation (插入排序实现)
import java.util.Arrays;
public class SortTest {
public static void insertionSort(int[] arr) {
// Start from the second element and move through the array
// 从数组的第二个元素开始遍历
for (int i = 1; i < arr.length; i++) {
int key = arr[i]; // The element to be inserted into the sorted portion
// 要插入到已排序部分的元素
int j = i - 1; // Start comparing with elements before the current one
// 从当前元素之前的元素开始比较
// Shift elements to the right to make space for insertion
// 将元素向右移动,为插入元素腾出空间
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j]; // Shift larger elements one position to the right
// 将较大的元素右移一个位置
j--; // Move the comparison index backward
// 继续向前比较
}
arr[j + 1] = key; // Insert the key at the correct position
// 将 key 插入到正确的位置
}
}
public static void main(String[] args) {
int[] arr1 = {3, 86, -20, 14, 40, 55}; // Example array
System.out.println("Before sorting: " + Arrays.toString(arr1));
insertionSort(arr1);
System.out.println("After sorting: " + Arrays.toString(arr1));
}
}
加分Project
点这里查看详情
从AP Classroom 中选一个已经做过的 FRQ,写出可执行代码,在blueJay中成功运行,具体要求和评分标准如下:
FRQ Coding Project Rubric / FRQ 编程项目评分标准
Grade | Guidelines | Criteria |
---|---|---|
A+ (9-10) | Exceptional work. Shows clear understanding and full mastery of the problem, and code is executed flawlessly. 出色的作品。展现了对问题的深入理解和完整掌握,代码运行无误。 |
|
A (8) | Excellent work. Code is accurate and runs without errors, with some minor style or completeness issues. 优秀作品。代码正确,运行无误,只有些微样式或完整性问题。 |
|
A- (7) | Strong work, but may have minor flaws in logic or structure. Code generally runs well. 表现良好,但在逻辑或结构上有小瑕疵。代码整体运行正常。 |
|
B+ (6) | Good effort with noticeable flaws. Code runs, but may have errors or inefficiencies. 有明显缺陷的良好尝试。代码可以运行,但可能有错误或低效部分。 |
|
B (5) | Satisfactory but needs improvement. Code has a mix of correct and incorrect results. 基本合格,但需改进。代码结果有正确和错误混合。 |
|
B- (4) | Acceptable, but with significant issues in execution, structure, or clarity. 可接受,但在执行、结构或清晰度上有重大问题。 |
|
C+ (3) | Limited success. Code runs but with minimal correctness, clarity, or efficiency. 成功有限。代码运行,但正确性、清晰度或效率低。 |
|
C (2) | Minimal success. Code compiles, but has many issues in logic and readability. 成功极少。代码可以编译,但逻辑和可读性有很多问题。 |
|
C- (1) | Very limited or incomplete. Code is far from functional and poorly constructed. 极其有限或不完整。代码几乎无法正常运行且结构糟糕。 |
|
Ask for Reflection / 提交时可能问你的问题:
- Why did you choose this particular FRQ? / 为什么选择这个特定的 FRQ?
- How did you approach solving the main problem? / 如何解决主要问题?
- Describe one challenge you faced and how you overcame it. / 描述遇到的一个挑战及如何克服。
End of semester project
点这里查看详情
Post-AP Project: Open-Ended Creative Challenge
After the AP CSA exam, you have time to design your own final project. This is your chance to reflect on your CS journey, explore your interests, and create something meaningful, fun, or challenging.
You will be graded on participation, weekly progress, and a final artifact of your choosing. This will culminate in a showcase presentation during the last week.
Timeline & Milestones
Week | Dates | Focus | Milestone / Deliverable |
---|---|---|---|
Week 1 | May 12–16 | Brainstorming & Kickoff | By Wednesday (May 14): Submit your project idea and goals via 交作业 page |
By Friday (May 16): Show initial setup or outline of your project (code, doc, sketch, etc.) | |||
Week 2 | May 19–23 | Development & Check-In | By Friday (May 23): Submit progress checkpoint + 1-paragraph reflection |
Week 3 | May 26–30 | Wrap-Up & Showcase | By Thursday (May 29): Submit final artifact + self-created rubric + reflection |
Exhibition Days | Friday (May 30): Final showcase/presentation in the temple |
Project Guidelines
- Format: You choose (video, slide deck, program, blog, infographic, mini-game, tutorial, etc.)
Must include:
- A final product or artifact
- A self-designed rubric (see below)
- A brief reflection (what you learned, enjoyed, or would do differently)
- Weekly checkpoints showing steady progress
Create Your Own Rubric (Required)
You will design your own grading rubric to go along with your final project. This rubric should reflect what you think are the most important qualities of your work. You’ll submit this rubric with your final artifact, and it will help guide how your project is evaluated.
How to Build Your Rubric:
- Choose 3–5 categories that are meaningful for your project.
- Use a consistent point scale (e.g., 1–5 or 1–10 for each category).
- Customize the descriptions to match the nature of your project.
- You can use the example below as a guide, but feel free to add, remove, or rename categories.
Example Rubric Template (Customize This!)
Category | Description (customize for your project!) | Max Points |
---|---|---|
Creativity & Originality | How unique or innovative is your idea or approach? | 10 |
Technical Execution | Is your code or product functional, well-structured, and effective? | 10 |
Communication & Clarity | Is the project well-presented or explained clearly (code, slides, video)? | 10 |
Personal Challenge | Did this push your comfort zone? Did you explore new concepts or tools? | 10 |
Completeness & Effort | Is the project thoughtfully developed and finished with care? | 10 |
Total Points: /50 (You can adjust this scale if your rubric uses different weights or categories)
Reminder: Your rubric should match your project. For example, if you're making a teaching video, “Clarity” might be more important than “Technical Execution.” If you're coding something complex, you might want to focus on design and logic quality.
How to Submit
Weekly Updates & Milestones Submit your progress updates (written description, bullet points, or summary) on our homework collection site: https://shishiapcs.github.io/CS-Homework-Collection/
Final Artifact & Rubric Submit your final project and scoring rubric by Wednesday (May 28) using one of the following methods:
- Airdrop (if you use a Mac): Send directly to the teacher before class ends
- Flash Drive: Bring your files and the teacher will copy them directly
Make sure your submission includes:
- The project artifact (file, folder, or link)
- Your custom rubric
- Your reflection paragraph
Core Concepts:
核心知识点
Java Class Sample:
//This is a Cat class. It is like a blueprint for making Cat objects.
// A class defines the characteristics(color and breed) and actions(meowing) of the objects.
public class Cat{
//Characteristics of the Cat class
//instance variables
private String color;
private String breed;
private int age;
private boolean isHungry;
private String name;
private double weight;
private double height;
// Default Constructor
public Cat(){
//This is a constructor. It is used to create a Cat object
//with some default values.
color = "unkown";
breed = "unkown";
age = 0;
isHungry = true;
}
// Constructor with parameters
public Cat(int a){
age = a;
}
public Cat(int a, String c){
age = a;
color = c;
}
public Cat(String c, int a){
color = c;
age = a;
}
// Methods
public void showAge(){
System.out.println("Age: " + age);
}
public void meow(){
System.out.println("Meow!!!");
}
public void eat(int foodAmount){
System.out.println("I eat " + foodAmount + " a day");
}
// Main method
public static void main(String[] args){
//int num = 2;
//System.out.println("num: " + num);
//int num2 = num;
//System.out.println("num2: " + num2);
//num = 9; //changing num later does not affect num2
//System.out.println("num2 after num change: " + num2);
//System.out.println("num after num change: " + num);
Cat littleCat = new Cat(20, "black");
//System.out.println("littleCat's color: " + littleCat.color);
Cat bigCat = littleCat;
//System.out.println("bigCat's color: " + bigCat.color);
littleCat.color = "pink";
//bigCat.showAge();
bigCat.eat(50);
//System.out.println("littleCat's color after change: " + littleCat.color);
//System.out.println("bigCat's color after change littleCat: " + bigCat.color);
}
}