Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Association list
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Performance== The disadvantage of association lists is that the time to search is {{math|[[Big O notation|''O''(''n'')]]}}, where {{mvar|n}} is the length of the list.<ref>{{cite book|first=Donald|last=Knuth|author-link=Donald Knuth|contribution=6.1 Sequential Searching|title=[[The Art of Computer Programming]], Vol. 3: Sorting and Searching|date=1998 |pages=396β405|publisher=Addison Wesley|edition=2nd|isbn=0-201-89685-0}}</ref> For large lists, this may be much slower than the times that can be obtained by representing an associative array as a [[binary search tree]] or as a [[hash table]]. Additionally, unless the list is regularly pruned to remove elements with duplicate keys, multiple values associated with the same key will increase the size of the list, and thus the time to search, without providing any compensatory advantage. One advantage of association lists is that a new element can be added in constant time. Additionally, when the number of keys is very small, searching an association list may be more efficient than searching a binary search tree or hash table, because of the greater simplicity of their implementation.<ref>{{cite book|title=Developer's Guide to Collections in Microsoft .NET|first=Calvin|last=Janes|publisher=Pearson Education|year=2011|isbn=9780735665279|page=191|contribution-url=https://books.google.com/books?id=-KdCAwAAQBAJ&pg=PT191|contribution=Using Association Lists for Associative Arrays}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)