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
Electromagnetic waves used in ovens and cell phone communications are called
Lera25 [3.4K]
<span>Microwaves are what  their called but im not for sure</span>
5 0
3 years ago
A<br> is an list of steps to complete a task. *
nlexa [21]

Explanation:

hope it helps

pls mark me brainliest thanks

4 0
2 years ago
Which of the following are examples of software? Check all of the boxes that apply.
dezoksy [38]

Hey!

------------------------------------------

<h3>Answers:</h3>

Operating System

Web Browser

Word Processor

Device Driver

------------------------------------------

<h3>Explanation:</h3>

Software is a set of data that tells the computer what to do. Each of the answer above tell the computer something specific to do.

The operating system are basic functions that make the computer run smoothly.

The web browser is telling the computer you want to look something up like in internet explorer, firefox, and chrome.

The word processor is a piece of software that tells the computer that you want to format a piece of text like in Microsoft word.

The device driver is a piece of software that controls a connected device like a phone or another computer.

------------------------------------------

Hope This Helped! Good Luck!

4 0
2 years ago
Read 2 more answers
In MS Word we can merga cells true or false​
sergey [27]
In this video I showed you all of the locations for all items in Wacky Wizards!! I hope you enjoyed and please like and subscribe. Piece out!!!
7 0
2 years ago
Read 2 more answers
Where is the "delete account" button in my profile? And please give me a legit answer and not just a word.
N76 [4]

Answer:

in your profile for brainley ??

3 0
2 years ago
Read 2 more answers
Other questions:
  • Writers should avoid jargon because jargon ______. a. Takes too long to use b. Limits what ideas can be explored c. Conveys too
    12·1 answer
  • What are the advantages of repeating a header row? check all that apply
    14·1 answer
  • What makes a distributed denial of service attack "distributed"? It involves many ip addresses. It attacks multiple systems. It
    9·1 answer
  • For each of these statements find a domain for which the statement is true and a domain for which the statement is false. a) Eve
    13·1 answer
  • When the continue statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignore
    5·1 answer
  • What do application in productivity suites have in common
    5·1 answer
  • I CANT DO SKIN MODS ON BRAWLHALLA RIGHT!!!! IM SO MADDDDDDDDDDD
    11·1 answer
  • The rectangle shape in flowchart is used for
    12·1 answer
  • What is the answer ????​
    9·1 answer
  • HELP 20 points THIS IS ON EDGE IF YOU DON'T KNOW THE ANSWER DON'T RESPOND
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!