-
Notifications
You must be signed in to change notification settings - Fork 1
LinkList
Vishnu Garg edited this page Aug 2, 2018
·
2 revisions
A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the below image:
package java.util;
public class LinkedList implements List,Deque {
private Node first;
private Node last;
public E get(int index) {…}
public boolean add(E e) {…}
public E remove(int index) {…}
[…]
}
Node Implementation
public class Node {
private E item;
private Node previous;
private Node next;
public Node(E element, Node previous, Node next) {
this.item = element;
this.next = next;
this.previous = previous;
}
[...]
}
Refrencses
- https://dzone.com/articles/linked-list-journey-continues
- https://www.geeksforgeeks.org/data-structures/linked-list/
- https://netjs.blogspot.com/2015/08/how-linked-list-class-works-internally-java.html
Every single element in a Doubly Linked List has a reference to its previous and next elements as well as a reference to an item, simplified as a number within a yellow box on this image above.