Is the PHP array a real array? what should I do?

Source: Internet
Author: User
Is the PHP array a real array? in PHP syntax, the subscript of an array can have a key similar to a hash, except a number. Is the ARRAY object in PHP not an ARRAY in the real data structure. At the same time, but when I set the KEY, can it be used as a HASH, and the read time complexity is not O (1 is the PHP array a real array?
In PHP syntax, the subscript of an array can have a key similar to a hash in addition to a number. Is the ARRAY object in PHP not an ARRAY in the real data structure. At the same time, when I set the KEY, can it be used as a HASH, and the read time complexity is O (1?

------ Solution --------------------
In PHP, arrays are implemented using a HASH structure (HashTable). PHP uses some mechanisms to add, delete, and delete arrays with time complexity of O (1, linear traversal and random access are also supported.
------ Solution --------------------
Discussion

No, it's a linked list.

------ Solution --------------------
The Array of PHP is the combination of List, hash, associated Array, and dictionary Hashtable.
Since array has the hashtable nature, the time complexity of reading through the key value is of course O (1!
------ Solution --------------------
If it is not a linked list, how do you explain the function?
Reset, prev, next, end

Also, the time complexity of the hash table is O (1)
This is theoretically true. it assumes that the key is long enough.
However, in actual applications, key conflicts are inevitable. Hash tables use sequential tables to compensate for key conflicts.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.