Arrays, linked lists

1, an array of
arrays in the physical memory allocation is continuous, the initialization time required to specify the size of memory.
Array access list by index, so the search efficiency is O (1), since the intermediate insertion, deletion, and insertion and deletion of the head to be moved to ensure that the subsequent data is a continuous array, so the middle and the head insertion and deletion efficiency is O (N), the modified consistent efficiency and search efficiency is O (. 1)
2, list
the list does not need to physically contact memory allocation, it is possible to make better use of memory chips, only initialized when the dispensing head memory size of the node.
Into a single list and doubly-linked list, a single node list stored in the index data fields and their rear nodes, the doubly linked list stored in the index, and the index of its own node data pre and post domain node.
Doubly linked list to find and delete improve efficiency, but save more than a pre-index node, is typical of the design space for time
to find the need to traverse the list to find, search efficiency single list of O (N), double-linked list can simultaneously Find backward from the head node and the end node from the front to find, like, doubly-linked list of search efficiency can be doubled.
Easy to insert and delete the list, knowledge of the circumstances node indices, as long as the time complexity of O (1), but without knowing the nodes of the index, if the insertions and deletions, first need to find the corresponding node then insert or deleted, in this case time complexity is O (N)

Guess you like

Origin www.cnblogs.com/youmingDDD/p/11574113.html