---
title: "Using Data Sets | FiveStudy"
description: "Draw the table first. Why every data-set algorithm visits values one at a time, what each one carries forward, and how a chart is used to plan the algorithm. AP CS A learning objective 4.2.A."
url: https://fivestudy.com/guides/using-data-sets
---

[AP Computer Science A](https://fivestudy.com/ap-computer-science-a) · Study guide

# Using Data Sets

[Figure: FiveStudy logo]

FiveStudy

Unit 4 · Topic 4.2

Unit 4 · Data Collections · Topic 4.2

# Using *Data Sets*

Draw the table first. Every data-set algorithm is one value at a time, and the table is where you find out which values and in what order.

Exam-day recap

- A **data set** is a collection of specific pieces of information or data.
- Values within a set are accessed and utilized **one at a time**, then processed according to the desired outcome.
- Because a program cannot see the whole set at once, every data-set algorithm is a **loop** that carries information forward.
- A chart or table is used to **plan the algorithm** that will manipulate the data — it is planning, not illustration.
- The **four question shapes**: total (running sum), count (matches), maximum (best so far), and a collection of matches.
- For a **total**, start at 0 and add every value; for a count, add one when the test passes.
- For a **maximum**, start at the first value and replace when a larger one appears.
- Seed a maximum with the **first value**, never 0: an all-negative set seeded at 0 reports a value not in the set.
- A vague question like "best player" is **not answerable** until it names the column being compared.
- Every algorithm follows the same shape: visit values in order, carry something forward, and report it at the end.

## 1What a Data Set Is

Essential knowledge 4.2.A.1

A **data set** is a **collection of specific pieces of information or data**.

Deliberately broad. A column of scores is a data set. A table of players and their statistics is a data set. A list of dates, a set of temperatures, a roster — all data sets. Nothing here says array, list, or file; those are representations, and they come later.

The learning objective

**4.2.A — represent patterns and algorithms that involve data sets found in everyday life using written language or diagrams.** Same shape as the algorithm topic in Unit 2: you are describing a process, not coding it. The exam skill paired with it is *determining what knowledge can be extracted from data*.

## 2One Value at a Time

Essential knowledge 4.2.A.2

Data sets can be **manipulated and analyzed to solve a problem or answer a question**. When analyzing data sets, values within the set are **accessed and utilized one at a time** and then **processed according to the desired outcome**.

That middle clause is the mechanical heart of Unit 4. A traversal does not take in the whole set at once the way your eye does when it looks at a table. It reaches one value, does something with it, then reaches the next.

Why this shows up everywhere later

"One at a time" is why the data-set algorithms in this unit are loops, and why the interesting decisions are always *what carries over between values*. A running total, a best-so-far, a count of matches — these exist because the program cannot look at everything simultaneously and must accumulate as it goes.

### 2.1 The Four Questions a Data Set Gets Asked

Almost every question put to a data set is one of these, and each has a characteristic thing that carries over:

| Question | What carries over | Example |
| --- | --- | --- |
| How much in total? | A running sum | Total games played by the roster |
| How many match a rule? | A count | How many players have vision score above 60 |
| Which is the most or least? | The best seen so far | Who has the highest KDA |
| Which ones qualify? | A growing collection | Every player with more than 20 games |

## 3Draw the Table First

Essential knowledge 4.2.A.3

Data can be **represented in a diagram by using a chart or table**. This visual **can be used to plan the algorithm** that will be used to manipulate the data.

The essential knowledge gives the table a job: it is not illustration, it is *planning*. Here is a data set for T1's starting five after a set of scrims:

| Handle | Role | Games | KDA | Vision score |
| --- | --- | --- | --- | --- |
| Doran | Top | 24 | 3.1 | 41 |
| Oner | Jungle | 26 | 4.0 | 58 |
| Faker | Mid | 26 | 4.6 | 44 |
| Peyz | Bot | 22 | 5.2 | 37 |
| Keria | Support | 26 | 3.4 | 92 |

With that in front of you, questions become answerable and, more importantly, the *algorithm* becomes visible.

### 3.1 Reading an Algorithm Off the Table

*Which player has the highest vision score?*

The algorithm the table suggests

1. Look at the first row. Remember that player as the best so far.
2. Move to the next row.
3. If this player's vision score is higher than the best so far, remember this player instead.
4. Repeat from step 2 until every row has been looked at.
5. The remembered player is the answer.

Five rows, five steps. The table stays put; the only thing that moves is which row is in hand and what is being carried:

Two steps that change nothing are still steps

Frames 3 and 4 look idle, and students often skip them when tracing by hand. They are where most trace errors come from: the row *was* read, the comparison *was* made, and the answer was no. Skipping a row is how a later value gets compared against the wrong carried value.

Tracing it against the table: Doran (41) is best so far, Oner (58) replaces him, Faker (44) does not, Peyz (37) does not, Keria (92) replaces Oner. Answer: Keria.

What the table gave you

Three things, none of which required any code. The **column** to look at, so the algorithm knows which value it is comparing. The **order** the rows are visited in, which is what makes "so far" meaningful. And a concrete **trace** to check the answer against — you knew Keria was right before you wrote a line.

### 3.2 A Question the Table Reveals as Ambiguous

*Who is the best player?*

The table refuses to answer, and that refusal is useful. Faker leads on KDA among the high-game players, Peyz has the highest KDA outright but the fewest games, and Keria's vision score dwarfs everyone's. "Best" names no column.

A question a data set cannot answer is not a programming problem yet

Before an algorithm can be written, the question has to name what is being compared. "Highest KDA" is answerable. "Best" is not, until someone decides what it means — and that decision belongs to a person, not to the loop.

### 3.3 When the Same Table Answers a Different Question

*How many players have played at least 25 games?*

A different algorithm, same data

1. Start a count at zero.
2. Look at the first row.
3. If this player's games is at least 25, add one to the count.
4. Move to the next row and repeat from step 3 until every row is done.
5. The count is the answer.

Oner, Faker and Keria qualify; Doran and Peyz do not. The count is 3. Note what changed from the previous algorithm and what did not: still one row at a time, still something carried over — but a count rather than a best-so-far, and a test rather than a comparison.

## 4Choosing What to Carry

Since values arrive one at a time, designing a data-set algorithm is mostly deciding what to remember between them:

| Goal | Start it at | Update rule |
| --- | --- | --- |
| Total | 0 | Add every value |
| Count of matches | 0 | Add one when the test passes |
| Maximum | The first value | Replace when a larger one appears |
| Collection of matches | An empty collection | Append when the test passes |

The maximum row is the odd one out

Totals and counts start at zero honestly. A maximum started at zero is wrong whenever every value is negative — the algorithm reports a number that is not in the data set. Seed it with the **first value**, which is always in the set by construction.

## 5Check Yourself

*Using the table above, what is the total number of games played by the roster?*

Response

124. Start a running total at 0 and add each row's games one at a time: 24, then 50, 76, 98, 124. The algorithm is the sum shape — carry a total, add every value, no test.

*Why does the course insist values are accessed "one at a time"?*

Response

Because it determines the shape of every algorithm that follows. A traversal does not take in the whole set at once, so these algorithms visit values in order and carry information forward. That is why the data-set work in this unit is a loop plus something remembered between passes.

*What is a chart or table for, according to the essential knowledge?*

Response

To **plan the algorithm** that will manipulate the data. It is a design tool, not decoration — it shows which values are involved, what order they are visited in, and gives you a worked answer to check the algorithm against.

*A data set of daily temperatures is all below freezing. An algorithm reports the maximum as 0. What went wrong?*

Response

The maximum was seeded at 0 instead of at the first value. Since no temperature ever exceeded 0, nothing replaced it, and the algorithm reported a value that does not appear in the data set at all. Seeding with the first value avoids this because that value is guaranteed to be in the set.

## 6Summary

| Idea | What to remember |
| --- | --- |
| **Data set** | A collection of specific pieces of information or data |
| **Purpose** | Manipulated and analyzed to solve a problem or answer a question |
| **Access** | Values are used *one at a time*, then processed toward the desired outcome |
| **Charts and tables** | A diagram of the data, used to *plan the algorithm* |
| **Every algorithm** | Visit in order, carry something forward, report it at the end |
| **The four shapes** | Total, count, maximum, collection of matches |
| **Seeding a maximum** | Use the first value, never zero |
| **Vague questions** | "Best" is not answerable until it names a column |

The habit

Draw five rows of the data before writing anything. Then answer the question by hand and watch what your own eye does — which column you looked at, what you kept track of as you went down the rows, and when you changed your mind. That is the algorithm, and you now have a worked example to test it against.

FiveStudy · AP Computer Science A · 2025–26

U4T2 · Using Data Sets · LO 4.2.A
