APCSP Unit 5 Test

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Traversal

"Visiting" or "touching" the elements of the structure, and doing something with the data; also sometimes called iterating over the data structure.

Index

A common method for referencing the elements in a list or string using numbers.

Substring

A part of an existing string.

Iteration

A repetitive portion of an algorithm which repeats a specified number of times or until a given condition is met.

Data Abstraction

A way to manage complexity in programs by giving a collection of data a name without referencing specific details.

Simulation

Abstractions of more complex objects or phenomena for a specific purpose.

Element

An individual value in a list that is assigned a unique index.

List

An ordered collection of elements.

Append

Concatenating linked lists or arrays in some high-level programming languages. Adding an item to a list.

For Loop

Condenses the parts of a while loop into a shorter statement. Similar to the while loop, once the Boolean expression becomes false, the loop ends.

A programmer has a need to round many numeric values to the nearest integer. Which of the following best explains the benefit of using a list as a data abstraction in this situation?

Keeping the numeric values in a list makes it easier to apply the same computation to every data element.

Infinite Loop

Occurs when the ending condition will never evaluate to true.

While Loop

Uses a boolean condition to repeatedly run a block of code. If it is true it runs the block of code contained within it. This process of checking the condition and running the block of code is repeated as long as the Boolean condition remains true. Once the Boolean expression becomes false it will stop.

Loop

Changes the sequential flow of control by repeating a set of statements zero or more times, until a stopping condition is met. Best when used for tasks that only need to be repeated in one place in your program.

Shoppers at a mall were asked whether they preferred wearing gloves or mittens in cold weather. Shoppers' preferences were stored in the listvoteList as strings, with the string "Gloves" representing a preference for gloves and the string "Mittens" representing a preference for mittens. The following code segment is intended to traverse the list and display the number of shoppers who chose gloves and the number of shoppers who chose mittens. numGlovesVotes ← 0 numMittensVotes ← 0 <MISSING CODE> { IF(vote = "Gloves") { numGlovesVotes ← numGlovesVotes + 1 } ELSE { numMittensVotes ← numMittensVotes + 1 } } DISPLAY(numGlovesVotes) DISPLAY(" shoppers chose gloves and") DISPLAY(numMittensVotes) DISPLAY(" shoppers chose mittens.") Which of the following should replace <MISSING CODE> so that the code segment works as intended?

FOR EACH vote IN voteList

Which of the following is a benefit of using a list as a data abstraction in a program?

Lists often allow their size to be easily updated to hold as many data values as needed.


Set pelajaran terkait

Stat 252- Linear Regression Multiple choice Exam

View Set

Clayton's Basic Pharmacology for Nurses Chapter 11

View Set

Test Four Unit 4 Context: Art History

View Set

Chp. 14: Somatosensory Function, Pain, Headache, and Temperature Regulation

View Set

Week 1 Module- Chapter 24 the office environment

View Set