Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
- Truly dynamic data structures
- The most simple dynamic data structures
- In depth understanding of reference
- In depth understanding of recursive
LinkedList achieve
Internal class Node, and for storing data next;
LinkedList Node has a variable type of pointing head.
- Add elements in the head List
- Adding an element in the middle List
- To delete an element in the specified location List
- Modify the elements in the specified location List
- Find specify the location of the element
Note: List here are achieved using a dummy head node dummyHead, dummyHead element value is null, next point to an index of 0 node.
Time complexity analysis
This is the analysis of the list is a single list:
- increase: , the head node list element increases time complexity is ;
- delete: , the time complexity is deleted element in node list head ;
- change:
- check:
Achieve stack as a linked list
Having a linked list queue tail pointer
Remove elements of the list:
To delete a node first find a node before the node is deleted. If the head node requires separate treatment, because there is no previous node of the head node. Another idea is to add a dummy head node, unified operation.