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
scoundrel [369]
3 years ago
5

Write a class that can make comparisons between the efficiency of the common methods from the List interface in the ArrayList an

d LinkedList classes such as add, get, and remove. Use the polymorphic-variable technique described above to write the class so that it only knows it is performing its tests on objects of the interface type List rather than on the concrete types ArrayList and LinkedList. Use large lists of objects for the tests, to make the results significant. You can use the currentTimeMillis method of theSystem class for getting hold of the start and finish time of your test methods.

Computers and Technology
1 answer:
Alika [10]3 years ago
6 0

Answer:

Check the explanation

Explanation:

CODE TO COPY:

File: ArrayListVsLinkedlIst.java

// ArrayListVsLinkedlIst class implementation

import java.util.*;

public class ArrayListVsLinkedlIst

{

  public static void main(String[] args)

  {

      // create a constant for the size of each list

      final int SIZE = 300000;

      // create the required objects

      List<Integer> aList = new ArrayList<Integer>();

      List<Integer> lList = new LinkedList<Integer>();

      // declare the required variables

      long start, end;

      int i;

      // comparison between the efficiency of the add() method

      // from the ArrayList and LinkedList classes

      System.out.println("Time in milliseconds to add " + SIZE

              + " numbers to each list ...");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          aList.add(i);

      }

      end = System.currentTimeMillis();

      System.out.println("ArrayList: " + (end - start) + " ms");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          lList.add(i);

      }

      end = System.currentTimeMillis();

      System.out.println("LinkedList: " + (end - start) + " ms");

      // comparison between the efficiency of the get() method

      // from the ArrayList and LinkedList classes

      System.out.println("\nTime in milliseconds to get " + SIZE

              + " numbers from each list ...");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          aList.get(i);

      }

      end = System.currentTimeMillis();

      System.out.println("ArrayList: " + (end - start) + " ms");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          lList.get(i);

      }

      end = System.currentTimeMillis();

      System.out.println("LinkedList: " + (end - start) + " ms");

      // comparison between the efficiency of the remove() method

      // from the ArrayList and LinkedList classes

      System.out.println("\nTime in milliseconds to remove " + SIZE

              + " numbers from each list ...");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          aList.remove(0);

      }

      end = System.currentTimeMillis();

      System.out.println("ArrayList: " + (end - start) + " ms");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          lList.remove(0);          

      }

      end = System.currentTimeMillis();

      System.out.println("LinkedList: " + (end - start) + " ms");

  }

} // end of ArrayListVsLinkedlIst class

The screenshot and output images can be seen below.

You might be interested in
What is a graphical representation of a real person in a virtual community called?
Hitman42 [59]
A graphical representation of a real person in a virtual community is an avatar.
8 0
3 years ago
The term that describes the connection of all kinds of devices; computers, phones, laptops, appliances, cars, etc. to the intern
Kryger [21]
This is hyped as the Internet of Things (IoT). Sometimes also called IoE, the Internet of Everything.
4 0
3 years ago
A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The n
OleMash [197]

Answer: EMI(Electromagnetic interference)

               RFI(Radio frequency interference)

Explanation: Electromagnetic interference is the emission of the electromagnetic signal that can disturb the working of the other device.It invokes the disturbance that can create error, under-performance mechanism,distortion etc in the equipment.

Radio-frequency interference(RFI) is the radio-frequency signal that interferes the other device by creating noise and distortion. This leads to breaking of the operation and data error.

Other options are incorrect because cross talk is referred as undesired communication between signal ,attenuation is the degradation in the  amplitude of any signal and extended length of cabling is increasing the length of the cable.Thus the correct answer is RFI and EMI.

4 0
3 years ago
To analyze data from a survey, you use a spreadsheet to calculate the percent of students who prefer corn over broccoli or carro
alisha [4.7K]

<u>Answer</u>:

<em>By changing the decimal to a percentage </em>

<u>Explanation:</u>

Since the requirement is to calculate the percentage of students about their preference in eating vegetables, we need to convert the given values to percentage only.  

<em> Option A: </em>By changing the addition sign to a multiplication sign. This is invalid because, there is no addition and multiplication involved in converting to percentage

<em>Option C:</em> By changing the percentage to a decimal. The given data is not available in percentage so conversion is impossible.

<em>Option D:</em> By changing the multiplication sign to a division sign Multiplication and division are not going to be performed here, since we need only percentage.

4 0
3 years ago
Read 2 more answers
A software development company wants to reorganize its office so that managers and the Computer Programmers they supervise can b
Lelechka [254]

The best way to increase collaboration between a supervisor and her or his subordinates, which in this case is the computer programmers, would be through option (A) remove the private offices and cubicles and replace them with large desks and conference tables out in the open.

By choosing to implement an open office layout, greater communication between the supervisor and computer programmers would occur compared to when they were separated.

7 0
3 years ago
Other questions:
  • _ is the use of a collection of computers, often owned by many people or different organizations, to work in a coordinated manne
    6·1 answer
  • Using the flowchart diagram, identify the decision point of this solution. Identify vendors. Calculate amount due. Determine dat
    12·2 answers
  • A program is a high-level one that has been converted to machine language
    15·1 answer
  • In 5-10 sentences, describe how computer networks work.
    6·1 answer
  • 12. Realizar un algoritmo que genere un número aleatorio, el usuario debe adivinar cual es el número generado para esto tendrá 3
    10·1 answer
  • When you complete a form online with your name, address, and credit card information in order to make a purchase, you are giving
    8·1 answer
  • You have used loops for repetitive processes.
    11·1 answer
  • What is the missing line?
    9·1 answer
  • Prepare the truth table for the following boolean expressions: (A+B).(A+C).(B)
    12·1 answer
  • explain how principles of computational thinking skills are applied in finding solutions that can be interpreted into software a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!