Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4) [8 Points] Write a method called BelowAvg to be included in class QueueEx. The method has one parameter q1 of type Arrayqueue of

image text in transcribed
Question 4) [8 Points] Write a method called BelowAvg to be included in class QueueEx. The method has one parameter q1 of type Arrayqueue of integers. The method finds the average of elements in q1, and moves every element in q1 less than the average to another queue that will be returned at the end of the method ( q1 will then be containing only the elements greater than the average). Assume that the queue is not empty and the class ArrayQueue is available for use. Use common queve operations only such as offer, poll, peek, IsEmpty and copy constructor. In the method, you must use the Iterator for the part related to finding the average, for the rest of the method it is up to you to use the Iterator or without iterator. [Note: The ArrayQueue class does not have size attribute (number of elements in the queue)]. The method head is public static ArrayQueue belownvg (ArrayoueuecInteger> qI) Example: \begin{tabular}{l} After method call: (Average is 9.5) \\ q2: 121015 \\ front rear \\ Returned Queues 479 \\ \multicolumn{4}{|c|}{ front rear } \\ \hline \end{tabular} public static ArrayQueuecInteger> belownvg(ArrayoueuecInteger q1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

Students also viewed these Databases questions