Detailed explanation and examples of two-way linked list in Java
Detailed explanation and examples of two-way linked list in Java
Write before:
Bidirectional linked list is a symmetrical structure, which overcomes the disadvantage of unidirectional pointer on single linked list. Each node can be referenced forward or backward, so it is more convenient to insert and delete data elements.
Because the bidirectional linked list needs to maintain pointers in both directions at the same time, the cost of pointer maintenance is greater when adding and deleting nodes; However, the two-way linked list has pointers in two directions, so it can search nodes in two directions. Therefore, the two-way linked list has good performance in searching nodes and deleting nodes at the specified index.
The Java language implements a two-way linked list:
Test class:
Program output:
Thank you for reading, hope to help you, thank you for your support to this site!