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
Bayley wants to connect a new external hard drive to his Windows PC. He wants the fastest connection type available because he p
PIT_PIT [208]

Answer:

Thunderbolt 3

Explanation:

Based on the scenario being described it can be said that in order to get the fastest connection possible Bayley needs a Thunderbolt 3 connection. This type of connection has become the standard due to it's theoretical maximum throughput of roughly 40 Gbps. This puts it at roughly double the speed of it's competing connection types, making it the fastest and best option.

8 0
3 years ago
Read 2 more answers
a marketing company is setting up a new office in the city. which type of contract should they sign for periodic maintenance of
True [87]

Answer:

The contract they had to sign was a computer maintenance contract with computer service providers.

Explanation:

<em>Why </em><em>do companies have to </em><em>maintain computers</em><em> regularly? </em>

Because of all the activities of the company at this time on average use applications from computers. With the maintenance of computers, the activities of the company will continue to run well.

There are two types of maintenance that can be carried out:

  • Hardware Maintenance
  • Software Maintenance

#AnswerForTrees

8 0
3 years ago
Write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and upda
Lady_Fox [76]

Answer:

Following are the statement is given below

if(updateDirection ==1) // check condition

{

++numUsers; // increments the value

}

else

{

--numUsers; // decrement the value

}

Explanation:

Following are the description of statement

  • Check the condition in the if block .If the "updateDirection" variable is 1 then then control moves to the if block otherwise control moves to the else block statement.
  • In the if  block the statement is "++numUsers" it means it increment the value by 1 .
  • In the else block the statement is "--numUsers" it means it decrement  the value by 1 .

4 0
3 years ago
PPPLLLLEEEEAAASSSSEEEEE HHELLP me.Does anyone know how to copy an image onto a thing so i can post a real question on brainly. b
Kitty [74]
If you're using a computer, you can take a picture on a camera, copy the picture to your computer to upload to Brainly.

If you're using a phone, you can easily upload pictures in the brainly App when you ask a question! just hit the camera button on the bottom left.
8 0
3 years ago
Read 2 more answers
1. row a statement you submit to get paid for a product or service 2. spreadsheet software used by many business professionals t
Ivenika [448]

Answer:

1. row a horizontal set of data in a spreadsheet  

2. spreadsheet software used by many business professionals to work with numbers  

3. data information that is stored  

4. template a file that serves as a starting point for a new document

5. function a built-in formula in a spreadsheet

6. invoice a statement you submit to get paid for a product or service

Explanation:

The correct matches have been mentioned in the answer section. Certainly, a row is the horizontal set of data is a spreadsheet. And other options are self-understood. And hence, it is self-explanatory.

6 0
3 years ago
Other questions:
  • A patent facilitates a government-approved technological monopoly by
    5·1 answer
  • Which of the following is something that scientists often seek by using computer models and simulations?
    8·2 answers
  • How to make flashcards on microsoft word 2010?
    7·1 answer
  • _____ are likely to support bigger government, social welfare programs, and legalized abortion.
    8·2 answers
  • 3. Assume a disk drive from the late 1990s is configured as follows. The total storage is approximately 675MB divided among 15 s
    11·1 answer
  • Microsoft vs Sony who wins ​
    13·2 answers
  • A computer is performing a binary search on the sorted list of 7 numbers below. What is the maximum number of iterations needed
    15·1 answer
  • Consider the following code:
    6·1 answer
  • Office 365 ProPlus can be deployed to your enterprise. When doing so, which tool enables you to choose the language, hardware ar
    5·1 answer
  • A user can add color to a database to highlight a modification. To do this with a macro, which command screen would you access o
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!