First draft: 2017-11-19 13:05:57
4 Types of linked list
- Non-circular single-linked list: The header node, so that the insertion delete operation is the same, do not have to specifically handle the insertion or deletion is the first position of the case.
- Circular single-linked list: The reference parameter is the pointer to the last node Ptail, so that you can quickly find the first node Phead = Ptail->next, but also quickly get the footer.
- Non-circular doubly linked list: node Q inserted after P point. Q->next = p->next; P->next->pre = q; P->next = q; Q->pre = p;
- Circular doubly linked list: a reference to the first or the end of a parameter.
The difference between a linked list and an array
Once the initial capacity of an array is determined, it can no longer be changed, which is appropriate for the amount of data to be processed.
Unknown the amount of data to be processed uses an array, which can cause wasted space or insufficient capacity, although dynamic arrays can be scaled up, but frequent expansion can cause significant overhead for the system.
The list capacity is unlimited, the length is the same as the number of elements, but requires additional space to store the next element of the address, the space usage is not an array.
Search by index, the time complexity of the array access element is O (1), the list is O (n)
Link list insertion and deletion time complexity is O (1), array is O (n)
The lookup value is an element of value and the velocity is the same.
List replenishment and the difference between linked list and array