Page 1 of 1

QI: You are required to implement a static generic method called deleteQueueOddPositions that removes the elements in od

Posted: Wed Apr 27, 2022 3:28 pm
by answerhappygod
Qi You Are Required To Implement A Static Generic Method Called Deletequeueoddpositions That Removes The Elements In Od 1
Qi You Are Required To Implement A Static Generic Method Called Deletequeueoddpositions That Removes The Elements In Od 1 (46.14 KiB) Viewed 40 times
QI: You are required to implement a static generic method called deleteQueueOddPositions that removes the elements in odd positions in a bounded queue. The method deleteQueueOddPositions receives a generic bounded queue as a parameter and delete odd positions elements. The original bounded queue should be unchanged except for the deleted odd positions elements. public static <T> void deleteQueueOddPositions (ArrayBndQueue <T>Q) //Your code should be here } As example: if the method receives Q= {10, 20, 30, 40, 50, 60) then after calling the method Q becomes: Q={10, 30, 50) Q2: You are required to implement a static method called nextSum that calculates the sum of each two adjacent elements in a stack. The nextSum method must take a stack sl as a parameter and the result should be a new stack s2 with the sum of each two adjacent elements in sl. The original stack should be unchanged. Examplel: if the method receives sl={10, 20, 30, 40, 50,60), s2={} then after calling the method si and s2 become: si= {10,20,30,40,50,60), s2 = {30, 70, 110 ) Example2: if the method receives sl={10, 20, 30, 40, 50), s2 } then after calling the method sl and s2 become: sl={10, 20, 30, 40, 50), s2 - {30, 70, 50) public static void nextSum (ArrayStack <Integer> sl, ArrayStack <Integer> sl)