Question: 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
Get step-by-step solutions from verified subject matter experts
