Fiveable
Fiveable
pep
Fiveable
Fiveable

or

Log in

Find what you need to study


Light

10.2 Recursive Searching and Sorting

12 min readjanuary 2, 2023

Athena_Codes

Athena_Codes

Milo Chang

Milo Chang

Athena_Codes

Athena_Codes

Milo Chang

Milo Chang

Using , we can make our searching and from much more concise, and we will also have new searching and that may be more efficient than our previous !

Searching - Linear/Sequential Search

We already covered this iteratively in Topic 7.5. As a reminder, here is the :

public static int linearSearch(ArrayList<Integer> array, int n) {
  for (int i = 0; i < array.size(); i++) {
    if (array.get(i) == n) {
      return i;
    }
  }
  return -1;
}

Here is the recursive version:

public static int recursiveLinearSearch(ArrayList<Integer> array, int n, int startingIndex) {
  if (array.get(startingIndex) == n) {
    return startingIndex; // base case #1: element found
  } else if (startingIndex == array.size() - 1) {
    return -1; //base case #2: element not found
  } else {
    //

Searching - Binary Search

Binary search is the new search algorithm that we'll learn in this unit, and it is quicker than linear sort. However, the tradeoff for the speed is that the list has to be presorted. Binary search will not work if the data is not presorted.

Here is its implementation, along with how it works both iteratively and recursively:

/** Uses binary search on a sorted ArrayList
*   1. Looks at the middle of the list, which divides it into two sublists
*   2. The left sublist is less than the middle and the right is greater
*   3. Compare the value to be searched for to the middle value
*   4. If this value > middle, repeat 1-3 to the right sublist
*   5. If this value < middle, repeat 1-3 to the left sublist
*   6. If this value = middle, return the middle value
*   7. Return -1 if value not found
*/
public static int binarySearch(ArrayList<Integer> array, int n) {
  int left = 0;
  int right = array.size() - 1;
  while (left <= right) { // left > right is "illegal"
    int middle = (left + right) / 2; // get the middle index of sublist
    if (n == array.get(middle)) { // item in middle of sublist
      return middle;
    } else if (n < array.get(middle)) { // item in left sublist
      right = middle - 1;
    } else if (n > array.get(middle)) { // item in right sublist, could just use else
      left = middle + 1;
    }
  }
  return -1; // item not in list
}

public static int recursiveBinarySearch(ArrayList<Integer> array, int n, int left, int right) {
  int middle = (left + right) / 2; // get the middle index of sublist
  if (left > right) { // base case #1: item not in list
    return -1;
  } else if (n == array.get(middle)) { // base case #2: item in middle of sublist
    return middle;
  } else if (n < array.get(middle)) { // 

Here is a visualization of binary search:

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-HlnhndXQlIqz.png?alt=media&token=fe6076a5-f908-4308-bcfa-6409cd55d477

Courtesy of Study.com.

Sorting - Insertion Sort

We already covered this iteratively in Topic 7.6. As a reminder, here is the :

/** Uses insertion sort on an ArrayList
*   1. Assume the first element is already sorted
*   2. Select the second element
*   3. Insert it before the first element or keep it in place to make the first 2 elements sorted
*   4. Select the third element and insert it so that the first 3 elements are sorted
*   5. Repeat until all elements are sorted.
*/
public static ArrayList<Integer> insertionSort(ArrayList<Integer> array) {
  for (int i = 1; i < array.length(); i++) {
    int currentElement = array.get(i);
    int currentIndex = i;
    for (int j = i; j > 0 ; j--) {
      if (currentElement < array.get(j - 1)) {
        // shifting the item left until properly placed by swapping consecutive items
        int itemToRight = array.get(j - 1);
        array.set(j - 1, currentElement);
        array.set(j, itemToRight);
      }
    }
  }
  return array;
}

Here is the recursive version:

public static ArrayList<Integer> recursiveInsertionSort(ArrayList<Integer> array, int index) {
  if (index == array.size()) { // base case: end of list reached, list sorted
    return array;
  } else {
    int currentItem = array.get(index)
    for (int i = index; i > 0; i--) { // shifting item to the left until sorted
      if (currentItem < array.get(i - 1)) {
        int itemToRight = array.get(i - 1);
        array.set(i - 1, currentItem);
        array.set(i, itemToRight);
      }
    }
    return recursiveInsertionSort(array, index + 1); // 

Sorting: Selection Sort

We already covered this iteratively in Topic 7.6. As a reminder, here is the :

/** Uses 

Here is the recursive version:

public static ArrayList<Integer> recursiveSelectionSort(ArrayList<Integer> array, int index) {
  if (index == array.size()) {
    return array;
  } else {
    int smallestIndex = index;
    int smallestElement = array.get(index);
    for (int i = index + 1; i < array.size(); i++) {
      if (array.get(i) < smallestElement) {
        smallestIndex = i;
        smallestElement = array.get(i);
      }
    }
    if (smallestIndex > index) {
      int originalItem = array.get(index);
      array.set(index, smallestElement);
      array.set(smallestIndex, originalItem);
    }
    return recursiveSelectionSort(array, index + 1);
  }
}
//To use this method:
recursiveInsertionSort(array, 0);

Sorting: Merge Sort

 is the new sorting algorithm learned in this unit, and it is quicker than insertion and . However, the tradeoff for the speed is that the algorithm requires more memory.

Here is its implementation, along with how it works both iteratively and recursively:

/** Performs 

Here is a visual look at :

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-fBPDBah93uyN.png?alt=media&token=13bed2a6-0c79-4827-bc0a-f0e9815e742c

Courtesy of Techie Delight.

Closing — What's Next?

If you've made it this far, congratulations, you've reached the end of AP Computer Science A! By now, you should be an expert on — loops, , and conditional statements, object orientated programming — , , , and polymormism, and basic — 1-D and 2-D arrays and ArrayLists!

If you're interested in further pursuing computer science, what comes next?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-56hZQPSjpKKm.gif?alt=media&token=b409bcce-2413-42ba-88f3-326b59e84dad

Courtesy of GIPHY.

You will most likely take a set of two courses, one being a more mathematically orientated and the other being more programming orientated. The first is a class, which covers the theory of discrete , which consists of things that we can count on our fingers, like whole numbers, as opposed to continuous , which are uncountable, such as real numbers. In this class, you'll learn a lot of so that we can understand programs and more. You will also learn and as well, which represent random and will help with machine learning and other fields where our methods are mostly consisting of random numbers with random outputs. Finally, you'll learn about , which are a type of that consists of different elements and connections between these elements.

On the other hand, the second Java course is a continuation of this course. You'll learn some advanced topics in and with the introduction of the interface and the abstract class and also make better loops, , and classes with what are known as invariants (which are the basis of the "Four Loopy Questions" in Unit 4). Then, you'll move onto more advanced , including the following:

  • The Linked List
    • These do not have indices but just pointers between one element and the next (and sometimes previous)
  • and other maps
    • These map one element to another which is like a dictionary word and its definition (the hash map uses a hash function like those described in Topic 9.7)
    • These are like lists, but are unordered and have nonduplicating items
    • These represent data in a branched structure, and are best when items have multiple different "levels"
    • Explained above, these represent data and connections between this data

You'll learn about these and also implement , being able to analyze how fast they run and how much memory they take up. Finally, you'll also learn to make GUIs, which are which display information in a visual manner.

With AP CSA and these two courses, these set up the foundation for any computer science that you will do afterwards, like , , , , , and so much more! The possibilities are endless! Moreover, there are many resources to learn these online as well and you don't need to go to a university to be a good programmer, but instead you can teach yourself and achieve great things!

If you have reached the end of this guide, thank you for sticking along on this journey through AP CSA. We as the Fiveable team have spent countless hours making and curating the best resources available for your use so that you can pass the AP exam and hopefully learn something new, fun, and insightful throughout this course that you can use later. We hope that you have found this information valuable and we wish you the best of luck on your AP exams and beyond!

Key Terms to Review (36)

Abstraction/Method Writing

: Abstraction is the process of simplifying complex systems by breaking them down into smaller, more manageable parts. Method writing refers to defining behaviors or actions that an object can perform.

Algorithm Analysis

: Algorithm analysis is the process of evaluating the efficiency and performance of an algorithm. It involves analyzing factors such as time complexity, space complexity, and scalability to determine how well an algorithm will perform in different scenarios.

Algorithms

: Algorithms are step-by-step procedures or instructions for solving problems or performing tasks. They provide clear instructions on how to solve problems efficiently.

Artificial Intelligence and Machine Learning

: Artificial Intelligence (AI) refers to the development of computer systems capable of performing tasks that typically require human intelligence, such as speech recognition or decision-making. Machine Learning (ML), a subset of AI, involves training algorithms on large datasets to make predictions or take actions without being explicitly programmed.

Control Structures

: Control structures are programming constructs that determine the flow of execution in a program. They allow you to make decisions and repeat actions based on certain conditions.

Data Structure

: A data structure is a way of organizing and storing data in a computer so that it can be accessed and used efficiently. It provides a systematic way to manage and manipulate data.

Data Structures

: Data structures are ways to organize, store, and manipulate data efficiently. They provide different methods of accessing, inserting, deleting, or searching for data elements based on specific requirements.

Discrete Math

: Discrete math is a branch of mathematics that deals with countable and distinct objects. It focuses on topics like sets, logic, relations, functions, and combinatorics.

Encapsulation/Class Writing

: Encapsulation is the practice of hiding internal details and providing a public interface for interacting with an object. Class writing involves defining the blueprint or template for creating objects in object-oriented programming.

Graphics

: Graphics involve creating visual representations using computers. It encompasses various techniques such as rendering 2D or 3D images, manipulating pixels, applying transformations, and simulating realistic effects like lighting and shadows.

Graphs

: Graphs are data structures that consist of nodes (vertices) and edges, where the edges represent relationships between the nodes. They are used to model connections or relationships between different entities.

GUIs (Graphical User Interfaces)

: GUIs, short for Graphical User Interfaces, are visual interfaces that allow users to interact with software applications using graphical elements such as buttons, menus, and windows. They provide an intuitive way for users to navigate through an application without needing extensive knowledge of programming languages.

Hash maps

: Hash maps are data structures that store key-value pairs, where each key is unique. They use a hash function to convert the key into an index in an array, allowing for efficient retrieval and insertion of values.

Inheritance

: Inheritance is a concept in object-oriented programming where a class inherits the properties and behaviors of another class. It allows for code reuse and promotes the creation of hierarchical relationships between classes.

Iterative Code

: Iterative code refers to programming constructs or algorithms that involve repetition using loops. It allows for executing a block of code multiple times until certain conditions are met.

Linear Search

: Linear search is a simple searching algorithm that sequentially checks each element in a list until it finds the target value or reaches the end of the list.

Logic and Proofs

: Logic and proofs involve the study of formal reasoning, including deductive reasoning, symbolic logic, truth tables, and proof techniques such as direct proof, contrapositive proof, and proof by contradiction.

Memory Analysis

: Memory analysis refers to the process of examining and understanding the contents of a computer's memory. It involves analyzing data structures, variables, and other information stored in memory to gain insights into how a program is functioning or to identify potential security vulnerabilities.

Memory Usage

: Memory usage refers to the amount of computer memory (RAM) that a program or process requires to run. It is a measure of how much space is occupied by data and instructions in the computer's memory.

Merge Sort

: Merge Sort is an efficient, comparison-based sorting algorithm that divides an unsorted list into smaller sublists, sorts those sublists recursively, and then merges them back together to obtain a sorted list.

Object-oriented programming (OOP)

: Object-oriented programming is a programming paradigm that organizes code into objects, which are instances of classes. It emphasizes the use of objects to represent real-world entities and their interactions.

Polymorphism

: Polymorphism refers to the ability of objects to take on multiple forms or have multiple types. In programming, it allows different objects to be treated as instances of a common superclass, enabling flexibility and extensibility.

Probability

: Probability is the branch of mathematics that studies uncertainty or randomness. It involves calculating the likelihood or chance that an event will occur based on mathematical models.

Programming Language Construction

: Programming language construction involves designing and implementing programming languages. It includes creating syntax rules, defining data types, and developing compilers or interpreters that translate code written in a specific language into machine-readable instructions.

Recursion

: Recursion is a programming technique where a function calls itself to solve a problem by breaking it down into smaller, similar subproblems.

Recursive Call

: A recursive call is when a function calls itself within its own code, allowing for repetitive execution of the same set of instructions.

Runtime Analysis

: Runtime analysis refers to analyzing the efficiency of an algorithm by measuring its execution time and memory usage. It helps determine how well an algorithm scales with input size.

Searching Algorithms

: Searching algorithms are methods used to find specific elements or values within a collection of data.

Selection Sort

: Selection Sort is a simple sorting algorithm that repeatedly finds the minimum element from an unsorted portion of the list and swaps it with the first element of that portion until the entire list is sorted.

Sequential Search

: Sequential search is another term for linear search, where each element in a list is checked one by one until the target value is found or the end of the list is reached.

Sets

: Sets are collections of unique elements with no specific order. They do not allow duplicate values and provide operations like union, intersection, and difference.

Sorting Algorithms

: Sorting algorithms are techniques used to arrange elements in a specific order (e.g., ascending or descending) within a collection of data.

State Machines

: State machines are computational models that consist of a set of states and transitions between those states. They are used to represent systems that change from one state to another based on inputs or events.

Trees

: Trees are hierarchical data structures consisting of nodes connected by edges. Each node has zero or more child nodes, except for the root node which has no parent. Trees are commonly used for organizing data in a hierarchical manner.

Unit 7

: Unit 7 refers to a specific section or module of study in the AP Computer Science A curriculum that focuses on topics such as arrays, ArrayLists, and searching algorithms.

Web Development

: Web development refers to the process of creating and maintaining websites. It involves designing, coding, and implementing various elements such as web pages, user interfaces, and databases.

10.2 Recursive Searching and Sorting

12 min readjanuary 2, 2023

Athena_Codes

Athena_Codes

Milo Chang

Milo Chang

Athena_Codes

Athena_Codes

Milo Chang

Milo Chang

Using , we can make our searching and from much more concise, and we will also have new searching and that may be more efficient than our previous !

Searching - Linear/Sequential Search

We already covered this iteratively in Topic 7.5. As a reminder, here is the :

public static int linearSearch(ArrayList<Integer> array, int n) {
  for (int i = 0; i < array.size(); i++) {
    if (array.get(i) == n) {
      return i;
    }
  }
  return -1;
}

Here is the recursive version:

public static int recursiveLinearSearch(ArrayList<Integer> array, int n, int startingIndex) {
  if (array.get(startingIndex) == n) {
    return startingIndex; // base case #1: element found
  } else if (startingIndex == array.size() - 1) {
    return -1; //base case #2: element not found
  } else {
    //

Searching - Binary Search

Binary search is the new search algorithm that we'll learn in this unit, and it is quicker than linear sort. However, the tradeoff for the speed is that the list has to be presorted. Binary search will not work if the data is not presorted.

Here is its implementation, along with how it works both iteratively and recursively:

/** Uses binary search on a sorted ArrayList
*   1. Looks at the middle of the list, which divides it into two sublists
*   2. The left sublist is less than the middle and the right is greater
*   3. Compare the value to be searched for to the middle value
*   4. If this value > middle, repeat 1-3 to the right sublist
*   5. If this value < middle, repeat 1-3 to the left sublist
*   6. If this value = middle, return the middle value
*   7. Return -1 if value not found
*/
public static int binarySearch(ArrayList<Integer> array, int n) {
  int left = 0;
  int right = array.size() - 1;
  while (left <= right) { // left > right is "illegal"
    int middle = (left + right) / 2; // get the middle index of sublist
    if (n == array.get(middle)) { // item in middle of sublist
      return middle;
    } else if (n < array.get(middle)) { // item in left sublist
      right = middle - 1;
    } else if (n > array.get(middle)) { // item in right sublist, could just use else
      left = middle + 1;
    }
  }
  return -1; // item not in list
}

public static int recursiveBinarySearch(ArrayList<Integer> array, int n, int left, int right) {
  int middle = (left + right) / 2; // get the middle index of sublist
  if (left > right) { // base case #1: item not in list
    return -1;
  } else if (n == array.get(middle)) { // base case #2: item in middle of sublist
    return middle;
  } else if (n < array.get(middle)) { // 

Here is a visualization of binary search:

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-HlnhndXQlIqz.png?alt=media&token=fe6076a5-f908-4308-bcfa-6409cd55d477

Courtesy of Study.com.

Sorting - Insertion Sort

We already covered this iteratively in Topic 7.6. As a reminder, here is the :

/** Uses insertion sort on an ArrayList
*   1. Assume the first element is already sorted
*   2. Select the second element
*   3. Insert it before the first element or keep it in place to make the first 2 elements sorted
*   4. Select the third element and insert it so that the first 3 elements are sorted
*   5. Repeat until all elements are sorted.
*/
public static ArrayList<Integer> insertionSort(ArrayList<Integer> array) {
  for (int i = 1; i < array.length(); i++) {
    int currentElement = array.get(i);
    int currentIndex = i;
    for (int j = i; j > 0 ; j--) {
      if (currentElement < array.get(j - 1)) {
        // shifting the item left until properly placed by swapping consecutive items
        int itemToRight = array.get(j - 1);
        array.set(j - 1, currentElement);
        array.set(j, itemToRight);
      }
    }
  }
  return array;
}

Here is the recursive version:

public static ArrayList<Integer> recursiveInsertionSort(ArrayList<Integer> array, int index) {
  if (index == array.size()) { // base case: end of list reached, list sorted
    return array;
  } else {
    int currentItem = array.get(index)
    for (int i = index; i > 0; i--) { // shifting item to the left until sorted
      if (currentItem < array.get(i - 1)) {
        int itemToRight = array.get(i - 1);
        array.set(i - 1, currentItem);
        array.set(i, itemToRight);
      }
    }
    return recursiveInsertionSort(array, index + 1); // 

Sorting: Selection Sort

We already covered this iteratively in Topic 7.6. As a reminder, here is the :

/** Uses 

Here is the recursive version:

public static ArrayList<Integer> recursiveSelectionSort(ArrayList<Integer> array, int index) {
  if (index == array.size()) {
    return array;
  } else {
    int smallestIndex = index;
    int smallestElement = array.get(index);
    for (int i = index + 1; i < array.size(); i++) {
      if (array.get(i) < smallestElement) {
        smallestIndex = i;
        smallestElement = array.get(i);
      }
    }
    if (smallestIndex > index) {
      int originalItem = array.get(index);
      array.set(index, smallestElement);
      array.set(smallestIndex, originalItem);
    }
    return recursiveSelectionSort(array, index + 1);
  }
}
//To use this method:
recursiveInsertionSort(array, 0);

Sorting: Merge Sort

 is the new sorting algorithm learned in this unit, and it is quicker than insertion and . However, the tradeoff for the speed is that the algorithm requires more memory.

Here is its implementation, along with how it works both iteratively and recursively:

/** Performs 

Here is a visual look at :

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-fBPDBah93uyN.png?alt=media&token=13bed2a6-0c79-4827-bc0a-f0e9815e742c

Courtesy of Techie Delight.

Closing — What's Next?

If you've made it this far, congratulations, you've reached the end of AP Computer Science A! By now, you should be an expert on — loops, , and conditional statements, object orientated programming — , , , and polymormism, and basic — 1-D and 2-D arrays and ArrayLists!

If you're interested in further pursuing computer science, what comes next?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-56hZQPSjpKKm.gif?alt=media&token=b409bcce-2413-42ba-88f3-326b59e84dad

Courtesy of GIPHY.

You will most likely take a set of two courses, one being a more mathematically orientated and the other being more programming orientated. The first is a class, which covers the theory of discrete , which consists of things that we can count on our fingers, like whole numbers, as opposed to continuous , which are uncountable, such as real numbers. In this class, you'll learn a lot of so that we can understand programs and more. You will also learn and as well, which represent random and will help with machine learning and other fields where our methods are mostly consisting of random numbers with random outputs. Finally, you'll learn about , which are a type of that consists of different elements and connections between these elements.

On the other hand, the second Java course is a continuation of this course. You'll learn some advanced topics in and with the introduction of the interface and the abstract class and also make better loops, , and classes with what are known as invariants (which are the basis of the "Four Loopy Questions" in Unit 4). Then, you'll move onto more advanced , including the following:

  • The Linked List
    • These do not have indices but just pointers between one element and the next (and sometimes previous)
  • and other maps
    • These map one element to another which is like a dictionary word and its definition (the hash map uses a hash function like those described in Topic 9.7)
    • These are like lists, but are unordered and have nonduplicating items
    • These represent data in a branched structure, and are best when items have multiple different "levels"
    • Explained above, these represent data and connections between this data

You'll learn about these and also implement , being able to analyze how fast they run and how much memory they take up. Finally, you'll also learn to make GUIs, which are which display information in a visual manner.

With AP CSA and these two courses, these set up the foundation for any computer science that you will do afterwards, like , , , , , and so much more! The possibilities are endless! Moreover, there are many resources to learn these online as well and you don't need to go to a university to be a good programmer, but instead you can teach yourself and achieve great things!

If you have reached the end of this guide, thank you for sticking along on this journey through AP CSA. We as the Fiveable team have spent countless hours making and curating the best resources available for your use so that you can pass the AP exam and hopefully learn something new, fun, and insightful throughout this course that you can use later. We hope that you have found this information valuable and we wish you the best of luck on your AP exams and beyond!

Key Terms to Review (36)

Abstraction/Method Writing

: Abstraction is the process of simplifying complex systems by breaking them down into smaller, more manageable parts. Method writing refers to defining behaviors or actions that an object can perform.

Algorithm Analysis

: Algorithm analysis is the process of evaluating the efficiency and performance of an algorithm. It involves analyzing factors such as time complexity, space complexity, and scalability to determine how well an algorithm will perform in different scenarios.

Algorithms

: Algorithms are step-by-step procedures or instructions for solving problems or performing tasks. They provide clear instructions on how to solve problems efficiently.

Artificial Intelligence and Machine Learning

: Artificial Intelligence (AI) refers to the development of computer systems capable of performing tasks that typically require human intelligence, such as speech recognition or decision-making. Machine Learning (ML), a subset of AI, involves training algorithms on large datasets to make predictions or take actions without being explicitly programmed.

Control Structures

: Control structures are programming constructs that determine the flow of execution in a program. They allow you to make decisions and repeat actions based on certain conditions.

Data Structure

: A data structure is a way of organizing and storing data in a computer so that it can be accessed and used efficiently. It provides a systematic way to manage and manipulate data.

Data Structures

: Data structures are ways to organize, store, and manipulate data efficiently. They provide different methods of accessing, inserting, deleting, or searching for data elements based on specific requirements.

Discrete Math

: Discrete math is a branch of mathematics that deals with countable and distinct objects. It focuses on topics like sets, logic, relations, functions, and combinatorics.

Encapsulation/Class Writing

: Encapsulation is the practice of hiding internal details and providing a public interface for interacting with an object. Class writing involves defining the blueprint or template for creating objects in object-oriented programming.

Graphics

: Graphics involve creating visual representations using computers. It encompasses various techniques such as rendering 2D or 3D images, manipulating pixels, applying transformations, and simulating realistic effects like lighting and shadows.

Graphs

: Graphs are data structures that consist of nodes (vertices) and edges, where the edges represent relationships between the nodes. They are used to model connections or relationships between different entities.

GUIs (Graphical User Interfaces)

: GUIs, short for Graphical User Interfaces, are visual interfaces that allow users to interact with software applications using graphical elements such as buttons, menus, and windows. They provide an intuitive way for users to navigate through an application without needing extensive knowledge of programming languages.

Hash maps

: Hash maps are data structures that store key-value pairs, where each key is unique. They use a hash function to convert the key into an index in an array, allowing for efficient retrieval and insertion of values.

Inheritance

: Inheritance is a concept in object-oriented programming where a class inherits the properties and behaviors of another class. It allows for code reuse and promotes the creation of hierarchical relationships between classes.

Iterative Code

: Iterative code refers to programming constructs or algorithms that involve repetition using loops. It allows for executing a block of code multiple times until certain conditions are met.

Linear Search

: Linear search is a simple searching algorithm that sequentially checks each element in a list until it finds the target value or reaches the end of the list.

Logic and Proofs

: Logic and proofs involve the study of formal reasoning, including deductive reasoning, symbolic logic, truth tables, and proof techniques such as direct proof, contrapositive proof, and proof by contradiction.

Memory Analysis

: Memory analysis refers to the process of examining and understanding the contents of a computer's memory. It involves analyzing data structures, variables, and other information stored in memory to gain insights into how a program is functioning or to identify potential security vulnerabilities.

Memory Usage

: Memory usage refers to the amount of computer memory (RAM) that a program or process requires to run. It is a measure of how much space is occupied by data and instructions in the computer's memory.

Merge Sort

: Merge Sort is an efficient, comparison-based sorting algorithm that divides an unsorted list into smaller sublists, sorts those sublists recursively, and then merges them back together to obtain a sorted list.

Object-oriented programming (OOP)

: Object-oriented programming is a programming paradigm that organizes code into objects, which are instances of classes. It emphasizes the use of objects to represent real-world entities and their interactions.

Polymorphism

: Polymorphism refers to the ability of objects to take on multiple forms or have multiple types. In programming, it allows different objects to be treated as instances of a common superclass, enabling flexibility and extensibility.

Probability

: Probability is the branch of mathematics that studies uncertainty or randomness. It involves calculating the likelihood or chance that an event will occur based on mathematical models.

Programming Language Construction

: Programming language construction involves designing and implementing programming languages. It includes creating syntax rules, defining data types, and developing compilers or interpreters that translate code written in a specific language into machine-readable instructions.

Recursion

: Recursion is a programming technique where a function calls itself to solve a problem by breaking it down into smaller, similar subproblems.

Recursive Call

: A recursive call is when a function calls itself within its own code, allowing for repetitive execution of the same set of instructions.

Runtime Analysis

: Runtime analysis refers to analyzing the efficiency of an algorithm by measuring its execution time and memory usage. It helps determine how well an algorithm scales with input size.

Searching Algorithms

: Searching algorithms are methods used to find specific elements or values within a collection of data.

Selection Sort

: Selection Sort is a simple sorting algorithm that repeatedly finds the minimum element from an unsorted portion of the list and swaps it with the first element of that portion until the entire list is sorted.

Sequential Search

: Sequential search is another term for linear search, where each element in a list is checked one by one until the target value is found or the end of the list is reached.

Sets

: Sets are collections of unique elements with no specific order. They do not allow duplicate values and provide operations like union, intersection, and difference.

Sorting Algorithms

: Sorting algorithms are techniques used to arrange elements in a specific order (e.g., ascending or descending) within a collection of data.

State Machines

: State machines are computational models that consist of a set of states and transitions between those states. They are used to represent systems that change from one state to another based on inputs or events.

Trees

: Trees are hierarchical data structures consisting of nodes connected by edges. Each node has zero or more child nodes, except for the root node which has no parent. Trees are commonly used for organizing data in a hierarchical manner.

Unit 7

: Unit 7 refers to a specific section or module of study in the AP Computer Science A curriculum that focuses on topics such as arrays, ArrayLists, and searching algorithms.

Web Development

: Web development refers to the process of creating and maintaining websites. It involves designing, coding, and implementing various elements such as web pages, user interfaces, and databases.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.