Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write pseudocode (or code) for the remove(int idx) method of the Arraylist ; that is, how would you remove an element from an arbitrary
1. Write pseudocode (or code) for the remove(int idx) method of the Arraylist ; that is, how would you remove an element from an arbitrary position of the array, maintaining all other elements in the array? For example, removing the element at index 2 from the ArrayList [1,3,2,4] would result in [1,3,4]. You may assume you have the following instance variables: int size , int max_size, int [] data. Remember to update the size of the array, and to handle the case where the index to remove is greater than the maximum index in the array (throw some sort of exception) public void remove(int idx): // answer here 2. Write pseudocode (or code) for the get(int idx) method of the ArrayList. Remember to handle error cases. public Element get(int idx): // answer here 3. Based on your answers to 1 and 2 , which is faster: or get (idx) ? Which one requires more work? 4. When might you want to use an Array instead of an ArrayList? 5. Name at least one limitation of the Array data type
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started