php arrays and linked lists What is the difference

  Php difference between an array and a linked list can be obtained from the following two ways:

  First, from a logical point of view the structure

  1, the array must be defined fixed length (number of elements), the case can not adapt to dynamic changes in the data. When the data is increased, the number of elements may exceed the previously defined; when the data is reduced, resulting in wasted memory; arrays can be directly accessed according to the following standard.

  Related free video tutorials to learn to share: php video tutorials

  2, the storage allocation list dynamically, where data can be adapted dynamically increases or decreases, and can be easily inserted, deleted data item. (When inserted into the array, delete a data item, the other data items need to move, very cumbersome) must find the next element in the list in accordance with the next pointer.

  Second, from the point of view of memory storage

  1, (static) allocates space from the stack array, fast and easy for programmers, but a small degree of freedom.

  2, the list allocated from the heap space, but a large degree of freedom of application management is too much trouble.

  As can be seen from the above comparison, if you need fast access to data, with little or no insert and delete elements, you should use the array; the contrary, if the need for frequent insert and delete elements you need to use a linked list data structure.

  Surrogacy prestige 15,023,219,993 Hefei , Taiyuan surrogate prestige 15,023,219,993 , Shanghai surrogate prestige 15,023,219,993 , Guangzhou surrogate +15023219993 , Chongqing surrogate +15023219993 related articles tutorials Recommended: php tutorial

Guess you like

Origin www.cnblogs.com/ipengrui1/p/12283398.html