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
AfilCa [17]
4 years ago
8

You are given an unsorted array x of elements that implement the Comparable interface. There are no duplicates in this array. Yo

u are also given a variable m of type Comparable. Write the code needed to assign to m a reference to the median value of the array. (You may modify the array x by rearranging its elements.)NOTE: The median of a set of values is the value in the set such that there are as many values that are greater as there are that are less. For purposes of THIS exercise, if the array has an even number of members, the median is the greater of the two middle values.
EXAMPLE 1: Given "bob" "carol" "ted" "alice" "fred" the median is "carol" because there are "bob" and "alice" are less than "carol" and "fred" and "ted" are greater.
EXAMPLE 2: Given "bob" "carol" "ted" "alice" "fred" "sue", the middle two values are "carol" and "fred" and so in THIS exercise we would consider the greater to be the median.
Computers and Technology
1 answer:
Andrei [34K]4 years ago
8 0

Answer:

boolean isEven = false;

if (x.length % 2 == 0)

isEven = true;

Comparable currentMax;

int currentMaxIndex;

for (int i = x.length - 1; i >= 1; i--)

{

currentMax = x[i];

currentMaxIndex = i;

for (int j = i - 1; j >= 0; j--)

{

if (((Comparable)currentMax).compareTo(x[j]) < 0)

{

currentMax = x[j];

currentMaxIndex = j;

}

}

x[currentMaxIndex] = x[i];

x[i] = currentMax;

}

Comparable a = null;

Comparable b = null;

if (isEven == true)

{

a = x[x.length/2];

b = x[(x.length/2) - 1];

if ((a).compareTo(b) > 0)

m = a;

else

m = b;

}

else

m = x[x.length/2];

You might be interested in
Spreadsheets: what is a column?
Travka [436]

Answer:

a group of cells stacked upon each other; vertical group

4 0
3 years ago
Select the correct text in the passage.
Serjik [45]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

As you know that noise distracts the process of communication. It is anything that distorts a message between two communicators. Noise can take many forms, such as playing the radio in the background, another person interfering with the conversation, and any other distraction that prevent the receiver from paying attention to what the sender is saying.

So, in this question, the noise phrase in the given passage is written in bold.

<em>Ben wanted to call his friend Kevin for a game of football. He rang up Kevin and was about to mention the game.</em> Just then, a car nearby honked loudly. <em>Kevin said that he couldn’t hear what Ben said. Ben then repeated what he had said earlier.</em>

A car honked nearly when Ben and Kevin are communicating with each other is considered noise. A car honked is a noise in the process of communication.    

4 0
3 years ago
Debug the following program.
mamaluj [8]

Answer:

The debugged program is as follows:

A=2

B=2

For I=1 to 10

PRINT A

TEMP = A

A=B

B=TEMP+A

NEXT I

END

Explanation:

First, the value of B should be changed to 4 (because the second term of the sequence is 2

Next, change Display to Print because Q-basic uses the print keyword to display output

The sequence is not properly generated. So, I update that part of the program to:

<em>For I=1 to 10 </em>

<em>PRINT A </em>

<em>TEMP = A </em>

<em>A=B </em>

<em>B=TEMP+A </em>

<em>NEXT I </em>

<em />

Lastly, the loop is controlled by variable I (not X).

So change NEXT X to NEXT I

4 0
3 years ago
PLEASE HELP!! FIRST ANSWER WILL MARK AS BRAINLIEST!!!
3241004551 [841]

Use the "As an Outlook Contact" option.

0 0
3 years ago
To make slides in a powerpoint online application presentation have the same transition effect, select __________ on the transit
Artemon [7]

Answer: Animations

Explanation:

Transitions, such as fade, can be applied to all using the command Ctrl+A.

Transitions are found under the animations Tab. Sorry about the bots.

Hope This Helped!

8 0
2 years ago
Other questions:
  • General Hardware Products Your boss, the IT director, wants you to explain FDDs, BPM, DFDs, and UML to a group of company manage
    13·1 answer
  • Which statement correctly explains why televisions became less bulky?
    6·1 answer
  • Which mistakes are NOT highlighted by the spell checker in a word-processing document?
    15·1 answer
  • A Windows computer on your network is having issues resolving queries for a specific domain, but not other domains. Other comput
    15·1 answer
  • Is the very calculation that we wish to avoid. Obtain a second equation by multiplying both sides of this equation by 1.06, then
    5·1 answer
  • A potentiometer a three wire variable resistor is used in which type of sensor ?
    13·1 answer
  • Which set of symbols encloses an if-then code block? Choose the best answer.
    10·1 answer
  • how risk can impact each of the seven domains of a typical IT infrastructure: User, Workstation, Local Area Network (LAN), Local
    7·1 answer
  • What menu and grouping commands is the "SORT" tool? ( please answering meeeee)
    9·1 answer
  • Is a list of instructions an arguments?<br> Yes or No
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!