Question: /******* Q1: [15 marks] * implement zip method in Q1 class to merge two linkedlists into one. * The elements in the result are made

 /******* Q1: [15 marks] * implement zip method in Q1 class
to merge two linkedlists into one. * The elements in the result

/******* Q1: [15 marks] * implement zip method in Q1 class to merge two linkedlists into one. * The elements in the result are made by concatenating elements in different * linkedlists one after one. The order of the elements matters. * For example, merge(listi, list2) should return (1,5,2,4,3,3,4,2,5,1]. * You can assume that arr1 and arr2 has the same size. * HINT: You should use ListIterator to make it easier. Integer[] arr1 = {1,2,3,4,5); Integer[] arr2 = {5,4,3,2,1); LinkedList list1 = new LinkedList(Arrays.aslist(arr1)); LinkedList list2 = new Linkedlist(Arrays.aslist(arr2)); System.out.println("Q1 [15 marks] System.out.println(Q1.zip(listi, list2)); BE class Q1 { public static LinkedList zip(Linkedlist listi, Linkedlist list2) //TODO return null

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!