Question 6 ArrayLists [15 marks] a. (5 marks) Trace the execution of method call foo (list, 10) and

Question 6 ArrayLists [15 marks] a. (5 marks) Trace the execution of method call foo (list, 10) and display the contents of list after the method finishes execution. No marks awarded for just stating the contents of the list without providing a trace public class TraceList public static void main (String [] ArrayList list list.add (10) ; list.add (20); list.add (10) list.add (10); list.add (10) ; list.add (30); list.add (10); foo (list, 10); args) new ArrayList ); T 10 11 //what are the contents of list here? 12 13 14 public static void foo (ArrayList < Integer > list, int target) { 15 16 for (int i 0; i if (list.get (i) list.remove (i); } list.size ; i++ target) 17 1 19 20 21 22 } 23 array-based list O(n) operation in the worst case scenario. Guideline for length of b. (5 marks) Briefly explain why removing an item from an is an answer: 40 to 60 words

 

Looking for a Similar Assignment? Hire our Top Uk Tutors while you enjoy your free time! All papers are written from scratch and are 100% Original. Try us today! Active Discount Code FREE15