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
What is the WiFi signal strength in different iPhone models?
Anika [276]
This is a really good question! WiFi signal strengths depend on the model of the WiFi receiver (which is in the iPhone) and the quality of the router sending out the signals.
8 0
3 years ago
Submit your 400-word essay that analyzes and evaluates three different examples of digital media. need some help
Vlada [557]

Answer:

Essay that analyzes and evaluates three different examples of digital media is described below in complete detail.

Explanation:

The 3 Types of Digital Media

  1. Owned Media
  2. Paid Media
  3. Earned Media
  • Owned media is what your label owns and manages. It doesn’t mean that you certainly own the program, but your corporation regulates the respective tales through which they publish their content about assistance and products.  
  • Paid media is considered attractive, and we’re all knowledgeable of it. It includes all marketing ways that a brand spends to get viewers. Here you spend a third-party program with specs on what you want.
  • Earned media is anything, whether content or remark, that stretches from another entity to help your brand. While most of it is optional, some expect you to contribute a substantial amount.

4 0
3 years ago
Erik is the president and owner of Watch Out, a local website development company that helps clients create and build unique web
11111nata11111 [884]

Answer:

A. Source code

Explanation:

In the field of Programming; Source code is the code written in high level language given to the computer to translate to machine -  executable code before executing. It is usually written and understood by human. It is closer to human like language, as it allows easier expression. It is mostly consist of english-like statement.

So, Erik would primarily be writing source code when performing his daily tasks since his daily task require high level of computer programming and internet knowledge.

5 0
3 years ago
What is the purpose of the website directory provided by the website host?
Dennis_Churaev [7]

Answer:

mabye A

Explana

.

.

.

6 0
3 years ago
How to calculate 3 X (50 + 40) ÷ 5 on excel 2016
kozerog [31]

Answer:

I think this might help, don't know much of this

Explanation:

How do you calculate 3.5 increase in Excel?

How To Increase a Number By a Percentage. If want to calculate a percentage increase in Excel (i.e. increase a number by a specified percentage), this can be done by simply multiply the number by 1 + the percentage increase. - which gives the result 60.

8 0
3 years ago
Read 2 more answers
Other questions:
  • ___ is the branch of computer science that explores techniques for incorporating aspects of intelligence into computer systems.
    5·1 answer
  • Several days a week, usually between 8:00 a.m. and 9:00 a.m., users complain of MWI problems. Some have new messages, but their
    11·1 answer
  • Dynamic alliance networks work best in industries: a. that are mature and stable in nature. b. where the coordination of product
    9·1 answer
  • . Virtualization simplifies the use of resources, isolates users from one another, supports replication and mobility, but exacts
    7·1 answer
  • You are a developer for a company that is planning on using the AWS RDS service. Your Database administrator spins up a new MySQ
    7·1 answer
  • PLS REPLY ASAP WILL MARK BRAINLIEST
    5·2 answers
  • What is modularity?
    9·1 answer
  • Write a description of the photograph to someone who cannot see the photograph. Be sure to include the title of the photograph a
    5·1 answer
  • Which generation computer supported GUI operating system?​
    11·1 answer
  • Calculate how many different pixel colours could be formed if one of the bytes gives the intensity of the red colour, one of the
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!