1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kkurt [141]
3 years ago
6

Write the function evens which takes in a queue by reference and changes it to only contain the even elements. That is, if the q

ueue initially contains 3, 6, 1, 7, 8 then after calling odds, the queue will contain 6, 8. Note that the order of the elements in the queue remains the same. For full credit, no additional data structures (queues, stacks, vectors, etc.) should be used. Assume all libraries needed for your implementation have already been included.
Computers and Technology
1 answer:
kvv77 [185]3 years ago
3 0

Answer:

Explanation:

The following code is written in Java it goes through the queue that was passed as an argument, loops through it and removes all the odd numbers, leaving only the even numbers in the queue. It does not add any more data structures and finally returns the modified queue when its done.

  public static Queue<Integer> evens(Queue<Integer> queue) {

       int size = queue.size();

       for(int x = 1; x < size+1; x++) {

           if ((queue.peek() % 2) == 0) {

               queue.add(queue.peek());

               queue.remove();

           } else queue.remove();

       }

       return queue;

   }

You might be interested in
"HotelExp” is a 3-D range name applied to the workbook shown.
Ganezh [65]

Answer:

all cells in the B column of any worksheet in this workbook

Explanation:

It seems each worksheet covers total expenses for each month, and hence workbook must have 12 such with one month for each worksheet. Also, the 3D range is a special option in Excel to reference all cells or a selected group of cells for all the worksheets. However, it should be all B cells as B2: B4 apart from this, others in B column also has expenses. And hence, the above option is the correct one.

3 0
3 years ago
Carol is working on her family farms to produce better variety of crops which have higher yields which process should carol use
Anettt [7]

Answer:

Genetic engineering

Explanation:

6 0
3 years ago
The __________ tool is present under the Windows Administrative Tools folder of the Start menu. Your answer​
Inga [223]
Administrative Tools
8 0
3 years ago
Which VMware product would allow administrators, to manage enterprise desktops with increased reliability, security, end-user ha
ahrayia [7]

Answer: Horizon

Explanation:

VMware Horizon Suite is a collection of products designed by VMware for Windows, Mac and Linux which allows administrators, to manage enterprise desktops with increased reliability, security, end-user hardware independence, and convenience

delivering data securedly on different remote devices.

7 0
3 years ago
How to know if java is installed on a server.
Leokris [45]

Answer:

Sorry, I don't know the answer.

Explanation:

mungkin kamu sendiri tau jawabannya

6 0
2 years ago
Other questions:
  • In the simulation, player 2 will always play according to the same strategy. The number of coins player 2 spends is based on wha
    6·1 answer
  • an error message is displayed during windws startup about a service that has failed to start, and then the system locks up. You
    7·1 answer
  • What component on a smartphone requires pairing with another device?
    8·1 answer
  • Pls help brainliest
    12·1 answer
  • Digital dashboards provide the decision makers with a quick overview of key performance indicators and other key operational sta
    13·1 answer
  • 8) The higher the drag coefficient, the_____ the car will go<br> a)Siower<br> b)Faster
    9·2 answers
  • A database administrator (DBA) must have a clear understanding of the fundamental business of an organization, be proficient in
    11·1 answer
  • Answer this blank:<br><br> Air enters through the mouth or nose, and travels through the _
    14·2 answers
  • Help plz
    10·1 answer
  • What are the things that a computer literate understands?Name thems.​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!