Hash tables VS associative arrays

后端 未结 5 1218
南旧
南旧 2020-12-07 14:06

Recently I have read about hash-tables in a very famous book \"Introduction to Algorithms\". I haven\'t used them in any real applications yet, but want to.

5条回答
  •  悲&欢浪女
    2020-12-07 14:41

    An array in PHP is actually an ordered map, not hashtable. Main difference between map and hashtable consists in inability to remember the order in wich elements have been added. On the other hand, hashtables are much faster than maps. Complexity of fetching an element from map is O(nlogn) and from hashtable is O(1).

提交回复
热议问题