Connected, double-linked, bidirectional linked list
I read in an article that there are such types of connected, doubly connected, and bidirectional
connected list.
I would like to ask, in Java
, LinkedList
- what list is this? And how do they differ?
2 answers
Connected (aka simply connected list), in Java terms, a list item is implemented something like this (in the good old days, when there were no collections, it was done like this):
class Entry<T> {
T data; //собственно сам контент
Entry<T> next; //ссылка на следующий элемент
}
An element of a doubly linked list like this:
class Entry<T> {
T data; //собственно сам контент
Entry<T> prev; //ссылка на предыдущий элемент
Entry<T> next; //ссылка на следующий элемент
}
In Java Collection, there is no pure implementation of a singly linked list, a doubly linked list is implemented in the form of LinkedList
Since time has passed, and there is no answer , I will leave my own.
The link to the article was also not provided, so I answer as I understand.
- A "connected" list, or in other words, a singly connected list, where each element refers only to the next one. The latter does not have a link.
- "Doubly connected" or doubly connected - a list where each element refers to the next and the previous one. The first and last respectively have no references to the previous and next.
- " Double a doubly linked list " is an oily mess, because in lists, the link sets the direction. In other words, it is the same as a doubly linked list. Singly connected - unidirectional, doubly connected-bidirectional.
In fact, taken hence.
Now about LinkedList. It implements three interfaces at once: List, Queue, and Dequeue. That is, it is a structure that stores the order of elements, supports adding elements at both ends, and allows itself to be traversed from both directions. Or in the terminology of the question is a doubly connected (bidirectional) list.