Data Structures and Algorithms: LinkedLists vs ArrayLists 🤼‍♂️

Data Structures and Algorithms: LinkedLists vs ArrayLists 🤼‍♂️

LinkedLists vs ArrayLists data structures and algorithms tutorial example explained

LinkedLists vs ArrayLists data structures and algorithms tutorial example explained


import java.util.ArrayList;
import java.util.LinkedList;

public class Main{

    public static void main(String[] args) {

        LinkedList<Integer> linkedList = new LinkedList<Integer>();
        ArrayList<Integer> arrayList = new ArrayList<Integer>();

        long startTime;
        long endTime;
        long elapsedTime;

        for(int i = 0; i < 1000000; i++){
            linkedList.add(i);
            arrayList.add(i);
        }

        // ****************LinkedList****************
        startTime = System.nanoTime();

        linkedList.get(0);
        //linkedList.get(500000);
        //linkedList.get(999999);
        //linkedList.remove(0);
        //linkedList.remove(500000);
        //linkedList.remove(999999);

        endTime = System.nanoTime();

        elapsedTime = endTime - startTime;

        System.out.println("LinkedList:\t" + elapsedTime +" ns");

        // ****************ArrayList****************    

        startTime = System.nanoTime();

        arrayList.get(0);
        //arrayList.get(500000);
        //arrayList.get(999999);
        //arrayList.remove(0);
        //arrayList.remove(500000);
        //arrayList.remove(999999);

        endTime = System.nanoTime();

        elapsedTime = endTime - startTime;

        System.out.println("ArrayList:\t" + elapsedTime +" ns");

    }
}

Subscribe:

data-science

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

How To Build A Data Science Career In 2021

In Conversation With Dr Suman Sanyal, NIIT University,he shares his insights on how universities can contribute to this highly promising sector and what aspirants can do to build a successful data science career.

Data Science Course in Bangalore | Data Science Training Bangalore - 360DigiTMG

Avail The Data Science Courses in Bangalore and Kick Start Your Career as a Successful Data Scientist in Bangalore within 4 months. Classroom/Online Data Science Course in Bangalore with Placements or Money Back.

What Are The Advantages and Disadvantages of Data Science?

Online Data Science Training in Noida at CETPA, best institute in India for Data Science Online Course and Certification. Call now at 9911417779 to avail 50% discount.

Data Science vs Big Data: Difference Between Data Science & Big Data

In the digital era that we live in, data has become the biggest and most valuable asset for most organisations. Data is rapidly transforming the way we live and communicate, and it is by collecting, sorting and studying this data, that organisations across the world are looking for ways to impact their bottom lines. In this post, we'll learn Data Science vs Big Data: Difference Between Data Science & Big Data.

50 Data Science Jobs That Opened Just Last Week

Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments. Our latest survey report suggests that as the overall Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments, data scientists and AI practitioners should be aware of the skills and tools that the broader community is working on. A good grip in these skills will further help data science enthusiasts to get the best jobs that various industries in their data science functions are offering.