Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Description

In this lesson, students will learn about four types of Data Structures. An array is a list of fixed size. An array list is a list of changing size. A 2D-Array is a grid, table, or list of lists. A Hash Map is a Key-Value store.

Objective

Students will be able to:

  • Explain the difference between an Array, an Array List, a 2D Array, and a Hash Map.
  • Choose the correct Data Structure for a given purpose
  • Understand how Data Structures fit into their programs
Description

In this lesson, students learn about arrays and make their first arrays. Arrays are one of the main data structures students will need to understand. This lesson introduces the idea, shows students how to create them, and explains how to access data elements to retrieve and update values.

Objective

Students will be able to:

  • Initialize an Array of various types
  • Access items in the list with indexes
  • Change the value of a list item using indexes
  • Find out the length of any array
Description

In this lesson, students will learn how to traverse an array to access all of the array elements. They will then apply this to real-world activities.

Objective

Students will be able to:

  • Create arrays of various types, including objects.
  • Traverse arrays using a for loop
  • Explain what happens when a program tries to access an array index that doesn’t exist
  • Explain how different arrays can point to the same value and the implication of this.
  • Apply arrays to real-world examples.
Description

In this lesson, students will explore enhanced for loops. An enhanced for loop is an alternate method to traverse an array instead of using a traditional for loop or while loop.

Objective

Students will be able to:

  • Traverse the elements in a 1D array object using an enhanced for loop
Description

In this lesson, students will learn about ArrayLists and make their own ArrayLists. They will then learn basic methods for ArrayLists to traverse, add, and access the elements in the ArrayList.

While this lesson focuses on ArrayLists, students should be starting to think about how Arrays and ArrayLists are similar and different. This concept is key and will be further explored in the next lesson.

Objective

Students will be able to:

  • Create an ArrayList
  • Add to and access ArrayList elements
  • Traverse an ArrayList
  • Use basic ArrayList methods
Description

In the lesson, students will learn more about the differences between Arrays and ArrayLists and make an ArrayList like class using an Array.

Having learned two different data structures for storing lists, it is only natural to compare and contrast these two structures. Students should come into this lesson with a basic understanding of differences but will develop a deeper understanding through a series of examples and activities.

Objective

Students will be able to:

  • Compare and contrast Arrays and ArrayLists.
  • Explain when to use ArrayLists versus Arrays.
  • Explain how ArrayList functionality can be built off an Array structure.
Description

In this lesson, students will explore the uses and properties that for and while loops have in common. Students will practice traversing ArrayLists using several types of loops.

Objective

Students will be able to:

  • Represent iterative processes using a for loop
  • Traverse ArraysLists using a for or while loop
  • Access elements in an ArrayList using iteration statements
  • Remove elements in an ArrayList
Description

In this lesson, students will learn about the list interface and use this to implement generic formal parameters and create classes that use the List interface.

This lesson is not currently in scope for the AP test, but understanding how to implement and use Java interfaces is a key concept for object-oriented programming.

Objective

Students will be able to:

  • Explain what the List interface is.
  • Explain why we would use the List interface as a formal parameter
  • Explain why we would use the List interface to define a List variable.
Description

In this lesson, students will learn about 2D arrays. The will also first be exposed to the idea of a nested loop, which will be used to access all the elements in a 2D array.

2D arrays are a key idea for students to grasp. They should spend time to fully understand how the loops execute. They can further supplement these concepts through the Traversing 2D Arrays exercises in the Supplemental Material.

Objective

Students will be able to:

  • Explain how 2D arrays are created by making an array of an array
  • Represent collections of related primitive or object reference data using two-dimensional (2D) array objects.
  • Traverse 2D arrays using nested loop statements.
Description

In this lesson, students will extend their learning on 2D arrays by traversing through them. When attempting to access all elements in a 2D array, we can do so in two different ways. Row-major order traverses the 2D array by accessing each value in a row before moving to the next row and column-major order traverses each column down all rows before moving to the next column.

Objective

Students will be able to:

  • Traverse 2D arrays using nested for loops
  • Traverse 2D arrays using nested enhanced for loops
Description

In this lesson, students will learn about HashMaps and use them to create solutions to real-world problems. HashMaps offer a different way of storing data in Java using a key/value pair. While this topic is out of scope for the AP test, it is a key data structure used in several programming languages and may make a good topic for after the AP test.

Objective

Students will be able to:

  • Explain what a HashMap is and when it should be used versus other data structures.
  • Create, modify, and retrieve values from a HashMap.
  • Loop through all values of a HashMap using an enhanced for loop.
Description

In this lesson, students learn how to convert from different number systems to decimal. They also learn more about why binary is used by computers and have an opportunity to write a code that will convert a binary number into a decimal number.

Objective

Students will be able to:

  • Convert by hand from binary, octal, and hexadecimal to decimal
  • Explain how to convert from any number system to decimal
  • Write basic computer programs to convert numbers to decimal
Description

In this lesson, students will discuss the ethical issues around how and why data is collected. They will look at the risks to personal privacy when working on computer systems and the internet and discuss how computer programs can have beneficial and/or harmful impacts on personal security. Lastly, the importance that programmers have in terms of safeguarding personal privacy will be considered and emphasized. This lesson corresponds with AP Computer Science A topic 7.7.

Objective

Students will be able to:

  • Explain the risks to privacy from collecting and storing personal data on computer systems
  • Explain the role that programmers have considering safeguarding personal privacy
  • Explain the beneficial and harmful impacts that computer use and the creation of programs have on personal security
Description

This lesson is a summative assessment of the unit’s learning objectives.

Objective

Students will be able to:

  • Demonstrate their knowledge of data structures in Java