Skip to main content

AP® Computer Science A Unit 4 flashcardsData Collections

40 cards · about 10 minutes for the whole deck

Flashcard drill

Space flips the card, arrow keys move, and keys 1 to 4 rate how well you knew it.

Position
1 / 40
Due
40
Mastered
0 / 40
Saved on this device · Sign in to sync

This card: New

Something wrong with this card?

What's wrong?

Please don't include personal details.

Flip the card before you rate it.

  • Personal privacy

    Collecting and storing personal data puts it at risk. Programmers should collect only what's needed and protect it.

    Topic 4.1: Ethical and Social Issues Around Data Collection

  • Algorithmic bias

    Repeated, systematic errors in a program that create unfair outcomes for a specific group, often because of biased data.

    Topic 4.1: Ethical and Social Issues Around Data Collection

  • Data quality

    Incomplete or inaccurate data, or data collected for a different question, can make a program give wrong answers.

    Topic 4.1: Ethical and Social Issues Around Data Collection

  • Data set

    A collection of related pieces of data, like a week of step counts. Programs analyze it to answer a question.

    Topic 4.2: Introduction to Using Data Sets

  • Processing one value at a time

    Data set algorithms visit each value in turn and update what they're tracking. Sketching the data in a table helps you plan this.

    Topic 4.2: Introduction to Using Data Sets

  • Array

    A fixed-size list of values of one type. new int[5] makes 5 elements starting at 0; the size can't change later.

    Topic 4.3: Array Creation and Access

  • Array length

    arr.length (no parentheses) is the number of elements. Valid indexes run from 0 to arr.length - 1.

    Topic 4.3: Array Creation and Access

  • Initializer list

    Creates and fills an array at once: int[] a = {3, 1, 4}; makes an array of length 3.

    Topic 4.3: Array Creation and Access

  • ArrayIndexOutOfBoundsException

    Thrown when you use an array index below 0 or at least length, like arr[arr.length].

    Topic 4.3: Array Creation and Access

  • Enhanced for loop

    for (int x : arr) visits each element without an index. x is a copy, so assigning to it doesn't change the array.

    Topic 4.4: Array Traversals

  • Consecutive pairs

    Compare arr[i] with arr[i + 1] for i from 0 to length - 2, or with arr[i - 1] starting at 1, so you never go out of bounds.

    Topic 4.5: Implementing Array Algorithms

  • Shift and rotate

    To rotate left, save arr[0], copy each element one place left, then put the saved value at the end. Shift right by looping from the back.

    Topic 4.5: Implementing Array Algorithms

  • Reversing an array

    Swap arr[i] with arr[arr.length - 1 - i] for i up to arr.length / 2. Going all the way swaps everything back.

    Topic 4.5: Implementing Array Algorithms

  • Text file

    Storage for data that lasts after the program stops. Open it with new Scanner(new File("data.txt")).

    Topic 4.6: Using Text Files

  • throws IOException

    Added to the header of a method that opens a file, saying what happens if it can't be opened: the program stops.

    Topic 4.6: Using Text Files

  • hasNext()

    Returns true if there's another item to read. while (input.hasNext()) reads a file until it's used up.

    Topic 4.6: Using Text Files

  • Scanner reading methods

    nextInt(), nextDouble(), nextBoolean() and next() read one item; nextLine() reads a whole line. Call close() when done.

    Topic 4.6: Using Text Files

  • InputMismatchException

    Thrown when nextInt, nextDouble or nextBoolean reads an item of the wrong type, like the word x.

    Topic 4.6: Using Text Files

  • split

    line.split(",") returns a String array of the pieces between commas: "3,4".split(",") is {"3", "4"}.

    Topic 4.6: Using Text Files

  • Wrapper class

    Integer and Double turn primitive values into immutable objects, so they can go in an ArrayList.

    Topic 4.7: Wrapper Classes

  • Autoboxing and unboxing

    Java converts automatically: Integer n = 5; boxes an int, and int k = n; unboxes it back.

    Topic 4.7: Wrapper Classes

  • Integer.parseInt and Double.parseDouble

    Turn a String into a number: Integer.parseInt("42") is 42 and Double.parseDouble("2.5") is 2.5.

    Topic 4.7: Wrapper Classes

  • ArrayList<E>

    A resizable list of objects from java.util. E is the element type, like ArrayList<String>; use Integer, not int.

    Topic 4.8: ArrayList Methods

  • add(index, obj)

    Inserts at index (0 to size()) and shifts later elements right. add(obj) adds to the end.

    Topic 4.8: ArrayList Methods

  • remove(index)

    Removes and returns the element at index, shifting later elements left, so their indexes drop by 1.

    Topic 4.8: ArrayList Methods

  • get and set

    get(i) returns the element at i. set(i, obj) replaces it and returns the old element; the size doesn't change.

    Topic 4.8: ArrayList Methods

  • Removing during a traversal

    Removing while looping forward skips the next element. Loop backward, or don't add 1 to i after a removal.

    Topic 4.9: ArrayList Traversals

  • ConcurrentModificationException

    Can be thrown when an ArrayList changes size inside an enhanced for loop over it. Use an indexed loop to add or remove.

    Topic 4.9: ArrayList Traversals

  • IndexOutOfBoundsException

    Thrown when an ArrayList index is out of range, like list.get(list.size()).

    Topic 4.9: ArrayList Traversals

  • Parallel traversal

    Using one index to walk through two lists or arrays at once, stopping at the end of the shorter one.

    Topic 4.10: Implementing ArrayList Algorithms

  • 2D array

    An array of arrays: g = new int[3][4] has 3 rows and 4 columns. g[r][c] is one element and g[r] is a whole row.

    Topic 4.11: 2D Array Creation and Access

  • Row-major order

    Visiting a 2D array across each row before moving down: the outer loop goes over rows and the inner loop over columns.

    Topic 4.12: 2D Array Traversals

  • Column-major order

    Visiting a 2D array down each column before moving right: the outer loop goes over columns and the inner loop over rows.

    Topic 4.12: 2D Array Traversals

  • Linear search

    Checks elements one at a time, from either end, until it finds the target (return its index) or runs out (return -1).

    Topic 4.14: Searching Algorithms

  • Selection sort

    Each pass finds the smallest remaining value and swaps it into its final place.

    Topic 4.15: Sorting Algorithms

  • Insertion sort

    Each pass takes the next value and shifts larger sorted values right to slide it into place. Its spot isn't final yet.

    Topic 4.15: Sorting Algorithms

  • Recursion

    A method that calls itself. It needs a base case that stops it and recursive calls that move toward that base case.

    Topic 4.16: Recursion

  • Base case

    The case where a recursive method returns without calling itself. Without reaching one, the calls never stop.

    Topic 4.16: Recursion

  • Binary search

    On sorted data, check the middle and discard the half that can't hold the target. At most 10 checks are needed for 1,000 values.

    Topic 4.17: Recursive Searching and Sorting

  • Merge sort

    A recursive sort: split the list in half, sort each half, then merge the two sorted halves into one.

    Topic 4.17: Recursive Searching and Sorting