AP Computer Science A • Unit 4.2

Introduction to Using Data Sets

Detailed answer explanations for the Unit 4.2 multiple-choice practice questions.

Q1B
Q2C
Q3C
Q4A
Q5C
Q6B
Q7C
Q8A
Q9D
How to use this page: First try each question without looking at the explanation. Then compare your answer with the key and read why the other choices are not correct.

Answer Explanations

Q1

Consider the following pseudocode and appointment data. What does the algorithm print?

sum <- 0
count <- 0
FOR EACH row IN AppointmentTable
    IF row.Status = "Scheduled"
        sum <- sum + row.Urgency
        count <- count + 1
    ENDIF
ENDFOR
avg <- sum / count
PRINT avg

Student      Urgency  Status
Alice K.        4     Scheduled
Bob D.          2     Completed
Michael S.      5     Scheduled
Javier T.       3     Canceled
A3.5
B4.5
C9
D14
Correct answer: B. Only the two rows whose Status is Scheduled update the running values, so sum ends at 9, count ends at 2, and avg prints 4.5.
Explanation

Selection filters the data set so the algorithm processes only the rows that matter to the question. The loop visits each row one at a time, but the IF test decides which rows are allowed to change sum and count. The final division happens once, after every row has been visited.

  • A is not correct: This is what you get by adding the Urgency of all four rows and dividing by four, which ignores the Status test that selects only the Scheduled rows.
  • C is not correct: This is the value held in sum after the loop finishes, reported before the algorithm divides by count to form the average.
  • D is not correct: This adds the Urgency value of every row, so it skips both the filtering condition and the division that turns a total into an average.
Q2

A program must answer this question about the data below. Which running values must the algorithm maintain as it visits each row?

Question: What percent of appointments were canceled?

Student      Service            Urgency  Status
Alice K.     Counseling            4     Scheduled
Bob D.       Academic Support      2     Completed
Michael S.   Wellness Check        5     Scheduled
Javier T.    Counseling            3     Canceled
AA count of canceled appointments only
BA running sum of the Urgency column and a count of rows
CA count of canceled appointments and a count of all rows
DA filtered list holding the canceled rows
Correct answer: C. A percent compares a part to a whole, so the algorithm must count the canceled rows and also count every row it visits.
Explanation

The desired outcome determines which fields the algorithm reads and which running values it maintains. Here the outcome needs two numbers built during the same pass: how many rows matched the condition, and how many rows there were in total.

  • A is not correct: Counting only the canceled appointments produces the part but never the whole, so there is nothing to compare it against.
  • B is not correct: A running sum of the Urgency column supports an average, which is a different outcome than the share of rows with a given status.
  • D is not correct: Holding the canceled rows themselves gives a filtered list, another outcome entirely, and it still leaves the total number of rows unrecorded.
Q3

What is a data set?

AAny group of values stored in the same file, even when they are unrelated
BA chart that must contain only numeric values
CA collection of related values or records
DA single summary value produced after an analysis
Correct answer: C. A data set is a collection of specific pieces of information that belong together because they can be used to study a question.
Explanation

What makes the values a data set is the relationship between them, not where they happen to be kept. The library loan, club attendance, and cafeteria order examples each group fields that support one line of questioning.

  • A is not correct: Storage location is not what joins the values; unrelated values placed together still cannot be used to study one shared question.
  • B is not correct: A chart is a way of picturing data to help plan the algorithm, and data set fields include categories and statuses as well as numbers.
  • D is not correct: A single value such as an average is an outcome the analysis produces from the data set, not the collection of records itself.
Q4

Which task is common when first using a data set?

AInspecting values and understanding what each field represents
BChoosing an algorithm before identifying the desired outcome
CTreating every numeric field as if it used the same units
DDiscarding labels because the values determine their own meaning
Correct answer: A. Before choosing an algorithm you inspect the labels, units, categories, and a few sample values so you know what each field means.
Explanation

A field name tells you what a stored value means, and without that meaning a program may process the correct value in the wrong way. The number 4 could be days borrowed, a shelf number, or a count, and each reading calls for a different operation.

  • B is not correct: The desired outcome is what determines which fields the algorithm reads and which running values it keeps, so it cannot be settled after the algorithm is picked.
  • C is not correct: Assuming shared units contradicts the advice to inspect units and categories, since a value read under the wrong unit is processed the wrong way.
  • D is not correct: Values do not announce their own meaning; the label is what tells you whether a number is days borrowed, a shelf number, or a count.
Q5

Why are labels or field names important in a data set?

AThey guarantee that every record is complete.
BThey determine whether a data set is large enough by themselves.
CThey explain what each value represents.
DThey remove the need to inspect units or categories.
Correct answer: C. A field name tells you what a stored value means, which is what lets the algorithm treat that value correctly.
Explanation

Without that meaning, a program may process the correct value in the wrong way. The number 4 could represent days borrowed, a shelf number, or a count, and each interpretation calls for a different operation.

  • A is not correct: A label describes what a field holds; it says nothing about whether a particular record actually supplies a value for that field.
  • B is not correct: Nothing about a field name reports how many records exist, so labels alone cannot settle whether there is enough data.
  • D is not correct: Units and categories are listed as separate things to inspect alongside the labels, so a name does not replace that inspection.
Q6

A missing value in a data set should usually be handled how?

AReplaced automatically with the largest observed value
BAccording to a clear rule before analysis
CIgnored because one missing value cannot affect a conclusion
DCounted as zero regardless of what the field represents
Correct answer: B. Fixing a clear rule before the analysis begins means every row is treated the same way as the algorithm visits records one at a time.
Explanation

The algorithm reads the needed fields from each row and updates a running value or decision. If the treatment of an absent value is decided as you go, the running values no longer reflect one consistent interpretation of the field.

  • A is not correct: Substituting the largest observed value pushes a sum or an average upward for a reason that has nothing to do with what the field represents.
  • C is not correct: Each row the algorithm visits can change a count, a sum, or a decision, so one unhandled value can still move the reported outcome.
  • D is not correct: Zero is itself a meaningful value in a field such as DaysBorrowed, so recording it ignores what the field was supposed to represent.
Q7

What is one reason to use a loop with a data set?

ATo make every record satisfy the same filtering condition
BTo guarantee that inconsistent values become valid
CTo process many values using repeated logic
DTo determine what each field represents without using labels
Correct answer: C. A loop lets the algorithm visit each row and apply the same steps again and again until every record has been processed.
Explanation

Values are accessed one at a time and processed according to the desired outcome. The loop is what repeats that access: read the needed fields, update a running value or decision, then move to the next row.

  • A is not correct: Repeating the test does not change the stored rows; selection instead filters the data set so only matching rows affect the outcome.
  • B is not correct: Running the same steps over the values leaves those values exactly as they were stored, so repetition cannot repair them.
  • D is not correct: Field meaning comes from the labels you inspect before choosing an algorithm, and repeating steps over the values does not recover it.
Q8

Which question helps check whether a data set is useful for a task?

ADoes it contain the values needed to answer the question?
BDoes it contain more records than every available alternative?
CCan every field be processed using the same operation?
DIs it organized as a table, even if key fields are missing?
Correct answer: A. A data set is useful for a task when it holds the values the question actually needs, both to test the condition and to produce the result.
Explanation

A table identifies each part of the algorithm: the condition fields, the output fields, and the written pattern. If the fields for those parts are absent, the question cannot be answered no matter how the data is arranged.

  • B is not correct: A larger pile of records is no help when the condition fields and output fields the question depends on are not among the columns.
  • C is not correct: Fields differ in units and categories, so a single operation applied to all of them would process some values the wrong way.
  • D is not correct: Rows and columns organize the data, but the arrangement cannot supply a field the question needs to test or report.
Q9

Which result is produced by analyzing unclean or inconsistent data without checking it?

AA representative result because every stored record was processed
BA correct result as long as the algorithm follows its steps
CA complete result because inconsistent values cancel one another
DPotentially misleading conclusions
Correct answer: D. When the values are not checked first, they may be interpreted the wrong way, so the outcome the algorithm reports can mislead.
Explanation

A field name tells you what a stored value means, and without that meaning a program may process the correct value in the wrong way. Inspecting labels, units, categories, and sample values before choosing an algorithm is what guards against that.

  • A is not correct: Visiting every stored record says only that the loop ran; it does not confirm the values it read meant what the algorithm assumed.
  • B is not correct: The steps can execute exactly as written and still combine values that were read under the wrong units or categories.
  • C is not correct: Nothing makes inconsistent values offset one another, and each one still enters the running sum, count, or decision.