Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

PLease help You need this in java please also explain what how the comparable interface works and also how a compareTo method works

Have the AList class implement the Comparable interface. Write the compareTo method to order lists this way:

First by size: a list that has fewer elements is smaller

Second, if the lists have the same number of elements: order by how many elements in the matching index of the other list are smaller; the list with more smaller elements in the matching position is smaller (see the examples below)

Note, to test your AList class, use these class and method headers:

public class AList implements ListInterface, Comparable>

public int compareTo(AList otherList)

You also need to change the lines in the constructor and toArray methods from using Object to using Comparable:

T[] tempList = (T[]) new Comparable[initialCapacity + 1];

T[] result = (T[]) new Comparable[numberOfEntries]; // Unchecked cast

Example:

List A: 1, 5, 6, 8, 10

List B: 2, 4, 3, 9, 7

In this example, List B is smaller because 3/5 elements in List B are less than their matching element in List A (4 < 5, 3 < 6, and 7 < 10).

List A: 1, 3, 5, 7, 10

List B: 2, 4, 3, 9, 7

In this example, List A is smaller because 3/5 elements in List A are less than their matching element in List B 1 < 2, 3 < 4, and 7 < 9).

List A: 1, 2, 3, 10, 9

List B: 2, 4, 3, 9, 7

In this example, neither is smaller because each has 2/5 elements smaller than their matching element in the other list.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93083356

Have any Question?


Related Questions in Computer Engineering

1 what is the purpose of exclusive gates such as the xor

1. What is the purpose of exclusive gates such as the XOR and XNOR? 2. What function do these gates perform?

Question students will turn a basic python set of files

Question : Students will turn a basic Python set of files into one single batch file. This will demonstrate students understanding of sequential scripting. Student will developed a simple 3-6 line code script file. Using ...

Using c language how to write a function name bsqrt that

Using C++ language, how to write a function name bsqrt that will compute the square root of a number using the Babylonian method. This function will take the number x to compute the square root for and the number of iter ...

Using jython 50 or higherwrite a 2-part program as

Using Jython 5.0 or Higher: Write a 2-part program as follows: Part 1: Write a function to convert Celsius to Fahrenheit Part 2: Write a function to convert Farenheit to Celsius Both of the functions (Celsius to Farenhei ...

Question research the recording industry association of

Question : Research the Recording Industry Association of America (RIAA) and the Motion Picture Association of America (MPA), their influence on Federal regulations, and their evolving role in digital media distribution. ...

You get hired as a machine learning expert at moviescom

You get hired as a Machine learning expert at movies.com. Your task on day one is to improve the performance of a classifier. You divide the data into 2 parts training, and testing. You learn a model from the training da ...

How technology government regulations international

How technology, government regulations, international factors, expectations about the future, and the macroeconomy play a role in managerial decision-making? Carefully explain each by giving example.

You are evaluating two different silicon wafer milling

You are evaluating two different silicon wafer milling machines. The Techron I costs $255,000, has a three-year life, and has pretax operating costs of $68,000 per year. The Techron II costs $445,000, has a five-year lif ...

Question suppose a wireless channel has a coherence

Question : Suppose a wireless channel has a coherence bandwidth of 100 kHz. What range of bit rates can be supported to have flat fading? The response must be typed, single spaced, must be in times new roman font (size 1 ...

Assignment week 3 create a scrum boardprojects that conform

Assignment: Week 3 Create a Scrum Board Projects that conform to the Agile methodology often use something called a scrum board. You can think of a scrum board as a digital whiteboard containing yellow "stickies," each l ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As