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
In procedural programming, where does the flow of control usually route from the main function?
Zinaida [17]

Answer:

Subroutine or called function.

Explanation:

Procedural programming is a programming techniques of creating modular divisions between lines of code, with a provision to call and run a block of code at any given instance in the program.

A program flow control breaks at will from the main function to a target defined function or subroutine, which returns a value back to the normal flow of the program. It uses conditional and loop statement to achieve its task.

6 0
3 years ago
Write a SELECT statement that returns these columns from the Orders table: The card_number column The length of the card_number
VashaNatasha [74]

Answer:

Select CardNumber, LEN(cardNumber) as CARDLEN,

Right (CardNumberR,4) AS LAST4DIGITS FROM ORDER

Explanation:

5 0
4 years ago
Layer 4 security and application services, including server load balancing, Secure Sockets Layer (SSL) offloading, firewalling,
Fittoniya [83]

Answer:

Layer 4 security and application services, including server load balancing, Secure Sockets Layer (SSL) offloading, firewalling, and intrusion prevention system (IPS) services are provided by the data center <u>aggregation</u> layer.

Explanation:

Consider the given information.

A key point for security and application services is the aggregation layer. In the data centre aggregation layer, the Layer 4 security and application services provide server load balancing, SSL offloading, firewalling, and IPS services.

Layer 4 security and application services, including server load balancing, Secure Sockets Layer (SSL) offloading, firewalling, and intrusion prevention system (IPS) services are provided by the data center <u>aggregation</u> layer.

7 0
3 years ago
Most users find settings between ____ to be the most convenient option for how long the computer sits idle before the screen sav
Sphinxa [80]
I would say about 5 to 10 minutes
3 0
4 years ago
Which IT job role best describes an individual who develops primarily server-side Web applications?
Hoochie [10]
Hi!

This is most likely going to be a back-end web developer. A back-end web developer focuses on the server-side scripting behind Web applications. 

They will also have extensive knowledge regarding the database used for the application at hand!

Hopefully, this helps! =)
6 0
4 years ago
Other questions:
  • The database management system is a program used to create, process, and administer a database.
    8·1 answer
  • How efficient would a 6-bit code be in asynchronous transmission if it had 1 parity bit, 1 start bit, and 2 stop bits?
    5·1 answer
  • An enterprise DBMS is automatically capable of serving as a mobile DBMS. There are no special issues raised by mobility. True Fa
    11·1 answer
  • Why is it important to use standard english when applying for a job
    13·2 answers
  • Upon combustion a .8009 g sample of a compound containing only carbon hydrogen and oxygen produced 1.6004 g of CO2 and .6551 g o
    10·1 answer
  • Implement function translate() that provides a rudimentary translation service. The function input is a dictionary mapping words
    9·1 answer
  • Motivational appeals refer to
    15·1 answer
  • What are two tasks that need to be done to a hard drive before operations can use it
    11·1 answer
  • Why does my inbox keep getting notifications and then disappearing?
    15·2 answers
  • Who was the first person to develop http the language in which servers and browsers communicate
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!