All Flashcards
What are the steps of adding an element at a specific index in an ArrayList?
- Specify the index and the element. 2. Shift existing elements to the right. 3. Insert the new element at the specified index.
What are the steps of removing an element at a specific index in an ArrayList?
- Specify the index. 2. Remove the element at that index. 3. Shift subsequent elements to the left.
What are the steps to convert an ArrayList to an array?
- Create a new array with the same size as the ArrayList. 2. Iterate through the ArrayList. 3. Copy each element from the ArrayList to the array.
What are the steps of linear search?
- Start at the beginning of the list. 2. Compare each element to the target. 3. If a match is found, return the index. 4. If the end is reached without a match, return -1.
What are the steps of selection sort?
- Find the minimum element in the unsorted portion. 2. Swap it with the first element of the unsorted portion. 3. Repeat for the remaining unsorted portion.
What are the steps of insertion sort?
- Assume the first element is sorted. 2. Pick the next element. 3. Insert it into the correct position in the sorted portion.
What are the steps for safe data handling?
- Use encryption. 2. Collect only necessary data. 3. Implement security measures. 4. Be transparent with users.
What are the steps to create an ArrayList?
- Import the ArrayList class. 2. Declare an ArrayList object. 3. Specify the data type using generics.
What are the steps to traverse an ArrayList using a for loop?
- Initialize a counter variable. 2. Loop through the ArrayList using the size() method. 3. Access each element using the get() method.
What are the steps to traverse an ArrayList using a for-each loop?
- Declare a variable of the ArrayList's data type. 2. Use the for-each loop to iterate through each element. 3. Access each element directly.
What is an ArrayList?
A dynamic data structure that stores an ordered collection of items.
What does 'mutable' mean in the context of ArrayLists?
Elements can be changed after the ArrayList is created.
What is a wrapper class?
A class that encapsulates a primitive data type, turning it into an object.
What is linear search?
A method for finding a target element in a list by checking each element sequentially.
Define selection sort.
A sorting algorithm that repeatedly finds the minimum element and moves it to the sorted portion of the list.
Define insertion sort.
A sorting algorithm that inserts each element into its correct position in the already sorted portion of the list.
What is encryption?
The process of converting plain text into a code to protect data from unauthorized access.
What is traversing an ArrayList?
Accessing and processing each element in the ArrayList, usually within a loop.
What is the Java Collections Framework?
A set of interfaces and classes that provide implementations for common data structures.
Define personal data.
Any information that relates to an identifiable individual.
How is ArrayList used in real-world scenarios?
Storing a list of customers in a database or managing a playlist of songs.
How is linear search applied in real-world scenarios?
Finding a specific product in a small inventory list.
How is selection sort applied in real-world scenarios?
Sorting a small list of student names alphabetically.
How is insertion sort applied in real-world scenarios?
Sorting a hand of cards as you receive them in a card game.
How is encryption used to protect user data?
Securing online transactions and protecting sensitive information from hackers.
Give a real-world example of ethical data collection.
A research study that obtains informed consent from participants before collecting their data.
How are ArrayLists used in social media applications?
Storing lists of friends, posts, or comments.
How are ArrayLists used in e-commerce applications?
Managing shopping carts and product lists.
How is data collection used in healthcare?
Tracking patient health records and monitoring disease outbreaks.
How is data collection used in education?
Tracking student performance and personalizing learning experiences.