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
Write a function swaparrayends() that swaps the first and last elements of the function's array parameter. ex: sortarray
Katena32 [7]
Def swapArrayEnds( array ):
    tmp = array[ len( array ) - 1 ]
    array[ len( array ) - 1 ] = array[ 0 ]
    array[ 0 ] = tmp


3 0
3 years ago
In Excel 2016 a range of cells beginning with cell C5 and going to cell E9 is defined as
Ksivusya [100]
None of the above.
Cell range should be marked as, C5:E9
5 0
3 years ago
When the Squirrel peer-to-peer web caching service was evaluated by simulation, 4.11 hops were required on average to route a re
bogdanovich [222]

Answer:An external caching scheme stores copies of web objects

or meta-data so that clients can avoid requests to a web

server. The best known example of an external cache is a

web proxy, but with the rapid spread of web technologies,

many other caching scenarios can be identified. Caching

is central to performance in the web, both because it re-

duces load on servers, and because cached data is normally

cheaper to access from another machine that is closer in the

network. Although cooperation between cache managers is

not a common feature of existing web architectures, coop-

erative caching supported by peer-to-peer architectures has

great potential [9, 13]. When sets of client systems have sim-

ilar interests and fast low-latency interconnections, shared

caching could bring significant benefits.

The peer-to-peer mechanisms referred to

Explanation:

4 0
3 years ago
DRU is a small brokerage house that enables its clients to buy and sell stocks over the Internet, as well as place traditional o
guapka [62]

Answer:

(A) A SMTP is a guideline that allows a client to send a message to the server in a network.

The web based mail is a kind of interface by which a correspondence occurs by applying the web explicit conventions or standards fro most of the time.

(B)The pros of an SMTP based two tie client server architecture are that, it has a free platform and a simple set up, also a detailed conversation between a client and a server.

The cons involve, having a blocked SMTP ports, and the slow execution of mass mail.

For the Web based the pros are, no blockages are found, email responses are very quick.

It's cons are, it has a complex kind of arrangement.

(C)What is recommended in this case for DRU is to use the SMTP based two tier client server architecture because, it is quicker, faster, secure and easy to fix.

Explanation:

Solution

(A) A Simple Mail Transfer Protocol (SMTP) is a standard in a which a customer sends messages over to the server in a network.

The sending of emails determines the manner of communication between the server and customer or client. this starts of with a TCP association with a particular port. the customer sends out different snippets of data, and then the server needs to have to look for the verification and email.

A web based email is a kind of interface where the correspondence occurs by making use of web -explicit conventions, for most of the time, the  HTTP will allow you to integrate capacities from assistance coming from outside into your application.

(B) (i) SMTP based two tier client server architecture:

The pros or advantages:

It is platform free and has a simple set up

A complete conversation or communication between the server and the client.

The cons or disadvantages:

A blocked SMTP ports

For a mass email it has a slow execution or implementation

(ii) For the web based the pros and cons is stated below:

The pros:

No blockage is found

Quick email response or transfer or movement.

Cons or disadvantages:

It has a complex or difficult arrangement

Complexity of any type increases or goes higher.

(C) What i will recommend for DRU will be the SMTP based two tier client server architecture due to the following reasons shown below:

It is quicker

It is faster

It is more secure/security

It does not require any high skill to use it;s service

It is easy to fix.

5 0
4 years ago
int[] num = new int[100];for (int i = 0; i &lt; 50; i++)num[i] = i;num[5] = 10;num[55] = 100;What is the value of num.length in
Lubov Fominskaja [6]

Answer:

Option 2: 100

Explanation:

The given code is regarding a Java array. To create an array in Java, the syntax is as follows:

type [] arrayname = new type[size]

In Java, this is possible to set a size for an array by giving an integer within the bracket. For example, int [] num = new int[100] will set the array size 100 for <em>num</em> . This means the <em>num</em>  can hold 100 components within the array.

Once the size is set for an array, the size cannot be changed in later stage.

6 0
3 years ago
Other questions:
  • An organism which must obtain its food from other organism is called a ​
    13·2 answers
  • What is an establishing shot, and when is it an appropriate shot choice in a film?
    15·2 answers
  • A programming and software development professional would most likely help with
    10·1 answer
  • ________ is an encryption standard used for secure transactions such as credit card processing and online banking. TLS DMZ White
    14·1 answer
  • Is technology uniting or isolating people
    14·2 answers
  • What are some difficulties in synchronizing audio and video during telecine transfer? (Select all that apply.)
    13·1 answer
  • Somebody supplied me with a file that was edited on a Windows machine. The file contains carriage returns in addition to the new
    9·1 answer
  • In Rizzati Corp, vice presidents in departments such as engineering, manufacturing, IT, and human resources report directly to t
    15·1 answer
  • What is your favorite video that Markiplier did with Bob, Wade, and Jack?
    8·1 answer
  • 3. Round off to the nearest hundredth (2 decimal places).
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!