How many elements in the matching index of the other list

Assignment Help Computer Engineering
Reference no: EM132095885

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<T extends Comparable> implements ListInterface<T>, Comparable<AList<T>>

public int compareTo(AList<T> 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.

Reference no: EM132095885

Questions Cloud

Example of decision making under certainty : Is the transportation method an example of decision making under certainty or decision making under uncertainty?
Was there an enforceable contact here : 1. Was there an enforceable contact here? Will Jamal be required to pay the extra $600 and if so, on what grounds?
Create a functional traffic light with oval shapes : Create a functional traffic light with oval shapes in visual basic, without using the powerpack to create the shapes.
Elements of the applied creativity-innovation model : There isn't any fixed number of words but it's more important to include all the 5 elements of the Applied Creativity & Innovation model.
How many elements in the matching index of the other list : If the lists have the same number of elements: order by how many elements in the matching index of the other list are smaller;
Evaluate the opportunities and threats that exist : The next stage of the marketing audit is for you to consider the market for your organisation and evaluate the opportunities and threats that exist
Write the method called stringsletters : Write the method called Strings.letters(String str) that returns a string of letters that only occur once in str, in the same order that they appear.
Write a program that gets ints from a file : Write a program that gets ints from a file. These are numerators and denominators, and you are to create Fractions.
A paint calculator that gives the customer the area : Create a CustomerData.txt file with 10 Customers including Customers Name, Room Name, Length of the Room, Width of the room and Height of the room.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd