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]
2 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]2 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
The term “computer literacy” dates back to what decade? <br> 1960s<br> 1970s<br> 1980s<br> 1990s
NNADVOKAT [17]
1970-80s which is when some of the first computers were created like apple computers which looked like a giant cube and a rectangle on the side which is very different than what we have today.

Hope this helps!
3 0
3 years ago
Which of the listed tools would a barber likely use in the following scenario?
Charra [1.4K]

Answer:

Please elaborate more your question so I can answer your question accurately.

Explanation:

6 0
2 years ago
How many days till earth ends
expeople1 [14]
Several Billion years
5 0
3 years ago
Who watches the show gravity falls, if you do, if you play the theme song for the first episode backwards you get a hiding messi
Yakvenalex [24]
I don’t really knowwww but thanks
4 0
2 years ago
Read 2 more answers
Systematically tackling the threats and vulnerabilities in the seven individual domains of a typical IT infrastructure helps you
Lorico [155]

Answer:

<u>Organize the roles, responsibilities, and accountabilities for risk management and risk mitigation. </u>

Explanation:

The seven domains in an IT structure can be identified as:

  1. User Domain,
  2. Workstation Domain,
  3. LAN Domain,
  4. WAN LAN Domain,
  5. Remote Access Domain,
  6. WAN Domain,
  7. and System / Application Domain

They can be configured as portals for countermeasure failure and intruders, so it is crucial for organizations to look for ways to protect these domains to prevent unauthorized access to private data.

Therefore the relevance of the systematic approach to threats and vulnerabilities, which will assist in organizing the roles, responsibilities and responsibilities for risk management and mitigation.

7 0
3 years ago
Other questions:
  • is this website just for a bunch of lazy kids bumming off answers? Because if that were the case I'd be one of them.
    9·1 answer
  • To find temporary windows files begin by typing in the search box
    6·1 answer
  • A multiplicative inverse of 3 modulo 5 is any integer a such that 3 a ≡ 1 (mod 5) , hence for some a ∈ Z5 .
    12·1 answer
  • You can create a database using one of the many templates available or by creating a new ______ database.
    9·1 answer
  • In the table below identify the data type that would be most suitable for the second field
    14·1 answer
  • Which button would you use to insert a downloaded video clip on your computer into a slide?
    15·2 answers
  • If you have 128 oranges all the same size, color, and weight except one orange is heavier than the rest. Write down a C++ Code/A
    7·1 answer
  • 2. Which pattern microphone should Jennifer take to the press conference? Jennifer is a journalist with one of the leading newsp
    14·1 answer
  • What are the specifications for a mine shaft headgear ​
    10·1 answer
  • Write a format operation that builds a string for the float variable amount that
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!