QI: You are required to implement a static generic method called deleteQueueOddPositions that removes the elements in od
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
QI: You are required to implement a static generic method called deleteQueueOddPositions that removes the elements in od
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)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!