1/12
These flashcards cover key concepts about ArrayLists, their methods and sorting algorithms relevant to the lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What are ArrayLists in Java?
ArrayLists are a collection object that uses arrays internally and can change size unlike traditional arrays.
How do you create an ArrayList in Java?
To create an ArrayList, you use: ArrayList
What is the role of wrapper classes in ArrayLists?
Wrapper classes allow ArrayLists to store primitive data types by using objects that behave like primitives.
What does it mean for an ArrayList to be pass by reference?
Changing an element of an ArrayList within a method modifies the original ArrayList due to pass by reference.
What method returns the size of an ArrayList?
The method size() returns the size of an ArrayList.
How does the add(index, element) method function in ArrayLists?
It adds an element at the specified index in the ArrayList or appends it at the end if index is omitted.
What does the get(index) method do?
The get(index) method returns the element located at the specified index in the ArrayList.
What is the purpose of the set(index, element) method?
The set(index, element) method replaces the element at the specified index with the given element and returns the replaced element.
What does the remove(index) method do?
The remove(index) method removes and returns the element at the specified index in the ArrayList.
How does selection sort work?
Selection sort finds the smallest element in the list and swaps it with the current element, progressively building a sorted list.
What are the key points of selection sort?
For a list of length n, it performs (n-1) comparisons and the number of swaps varies depending on the data.
What is insertion sort?
Insertion sort inserts each element into its correct position in a pre-sorted subsection of the list.
What are the key points of insertion sort?
For a list of length n, it performs n-1 insertions and its comparisons can range from 0 to (n-1)th triangular number.