Junior — Middle
What is the name of the situation when an object contains references to its previous and next elements in the chain?
sobes.tech AI
Answer from AI
This situation is called a doubly linked list. In a doubly linked list, each element (node) contains a reference to the previous and next elements, which allows efficient traversal in both directions along the chain.
Example of a doubly linked list node in Java:
class Node {
int data;
Node prev;
Node next;
Node(int data) {
this.data = data;
this.prev = null;
this.next = null;
}
}