In this assignment, you will compare the performance of ArrayList and LinkedList. More specifically, your program should measure the time to “get” and “insert” an element in an ArrayList and a LinkedList. You program should 1. Initialize i. create an ArrayList of Integers and populate it with 100,000 random numbers ii. create a LinkedList of Integers and populate it with 100,000 random numbers 2. Measure and print the total time it takes to i. get 100,000 numbers at random positions from the ArrayList 3. Measure and print the total time it takes to i. get 100,000 numbers at random positions from the LinkedList 4. Measure and print the total time it takes to i. insert 100,000 numbers in the beginning of the ArrayList 5. Measure and print the total time it takes to i. insert 100,000 numbers in the beginning of the LinkedList 6. You must print the time in milliseconds (1 millisecond is 1/1000000 second). A sample run will be like this: Time for get in ArrayList(ms): 1 Time for get in LinkedList(ms): 4115 Time for insertion in ArrayList(ms): 1376 Time for insertion in LinkedList(ms): 7 II. Implementation Requirements You may use any implementation mechanism for random numbers and timers. The followings are suggested. • You can use java.util.Random class to create random numbers. • You can use the System.nanoTime() method to get the system timer in nanoseconds (1 nanosecond is 1/1000000000 second). • To measure the time of execution of some code, you need to call the timer before and after the execution. long startTime = System.nanoTime(); //code whose execution is measured long endTime = System.nanoTime(); long executionTime = (endTime - startTime); //in nanoseconds

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In this assignment, you will compare the performance of ArrayList and LinkedList. More specifically, your
program should measure the time to “get” and “insert” an element in an ArrayList and a LinkedList.
You program should
1. Initialize
i. create an ArrayList of Integers and populate it with 100,000 random numbers
ii. create a LinkedList of Integers and populate it with 100,000 random numbers
2. Measure and print the total time it takes to
i. get 100,000 numbers at random positions from the ArrayList
3. Measure and print the total time it takes to
i. get 100,000 numbers at random positions from the LinkedList
4. Measure and print the total time it takes to
i. insert 100,000 numbers in the beginning of the ArrayList
5. Measure and print the total time it takes to
i. insert 100,000 numbers in the beginning of the LinkedList
6. You must print the time in milliseconds (1 millisecond is 1/1000000 second).
A sample run will be like this:
Time for get in ArrayList(ms): 1
Time for get in LinkedList(ms): 4115
Time for insertion in ArrayList(ms): 1376
Time for insertion in LinkedList(ms): 7
II. Implementation Requirements
You may use any implementation mechanism for random numbers and timers. The followings are suggested.
• You can use java.util.Random class to create random numbers.
• You can use the System.nanoTime() method to get the system timer in nanoseconds (1
nanosecond is 1/1000000000 second).
• To measure the time of execution of some code, you need to call the timer before and after the execution.
long startTime = System.nanoTime();
//code whose execution is measured
long endTime = System.nanoTime();
long executionTime = (endTime - startTime); //in nanoseconds

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Hash Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education