CINXE.COM
Linked list - Wikipedia
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Linked list - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"1b0284e4-76bc-419e-a4be-6cb84413e5c4","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Linked_list","wgTitle":"Linked list","wgCurRevisionId":1270124078,"wgRevisionId":1270124078,"wgArticleId":18167,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["CS1: long volume value","CS1 errors: periodical ignored","Articles with short description","Short description is different from Wikidata","Articles lacking in-text citations from March 2012","All articles lacking in-text citations","All articles with unsourced statements","Articles with unsourced statements from January 2019","Pages with plain IPA","Wikipedia articles needing clarification from October 2011","Commons category link is on Wikidata","Articles with example C code","Linked lists"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Linked_list","wgRelevantArticleId":18167,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":60000,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q7003418","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false}; RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.cite.styles":"ready","ext.pygments":"ready","ext.math.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","jquery.makeCollapsible.styles":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready"};RLPAGEMODULES=["ext.cite.ux-enhancements","ext.pygments.view","site","mediawiki.page.ready","jquery.makeCollapsible","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.growthExperiments.SuggestedEditSession"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&modules=ext.cite.styles%7Cext.math.styles%7Cext.pygments%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cjquery.makeCollapsible.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.20"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Linked list - Wikipedia"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/Linked_list"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Linked_list&action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/Linked_list"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Linked_list rootpage-Linked_list skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" title="Main menu" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li> </ul> </div> </div> <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" > <div class="vector-menu-heading"> Contribute </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li><li id="n-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages"><span>Special pages</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Main_Page" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page's font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&returnto=Linked+list" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&returnto=Linked+list" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&returnto=Linked+list" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&returnto=Linked+list" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">(Top)</div> </a> </li> <li id="toc-History" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#History"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>History</span> </div> </a> <ul id="toc-History-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Basic_concepts_and_nomenclature" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Basic_concepts_and_nomenclature"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Basic concepts and nomenclature</span> </div> </a> <button aria-controls="toc-Basic_concepts_and_nomenclature-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Basic concepts and nomenclature subsection</span> </button> <ul id="toc-Basic_concepts_and_nomenclature-sublist" class="vector-toc-list"> <li id="toc-Singly_linked_list" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Singly_linked_list"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Singly linked list</span> </div> </a> <ul id="toc-Singly_linked_list-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Doubly_linked_list" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Doubly_linked_list"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2</span> <span>Doubly linked list</span> </div> </a> <ul id="toc-Doubly_linked_list-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Multiply_linked_list" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Multiply_linked_list"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3</span> <span>Multiply linked list</span> </div> </a> <ul id="toc-Multiply_linked_list-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Circular_linked_list" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Circular_linked_list"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.4</span> <span>Circular linked list</span> </div> </a> <ul id="toc-Circular_linked_list-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Sentinel_nodes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Sentinel_nodes"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.5</span> <span>Sentinel nodes</span> </div> </a> <ul id="toc-Sentinel_nodes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Empty_lists" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Empty_lists"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.6</span> <span>Empty lists</span> </div> </a> <ul id="toc-Empty_lists-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Hash_linking" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Hash_linking"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.7</span> <span>Hash linking</span> </div> </a> <ul id="toc-Hash_linking-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-List_handles" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#List_handles"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.8</span> <span>List handles</span> </div> </a> <ul id="toc-List_handles-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Combining_alternatives" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Combining_alternatives"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.9</span> <span>Combining alternatives</span> </div> </a> <ul id="toc-Combining_alternatives-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Tradeoffs" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Tradeoffs"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Tradeoffs</span> </div> </a> <button aria-controls="toc-Tradeoffs-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Tradeoffs subsection</span> </button> <ul id="toc-Tradeoffs-sublist" class="vector-toc-list"> <li id="toc-Linked_lists_vs._dynamic_arrays" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Linked_lists_vs._dynamic_arrays"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1</span> <span>Linked lists vs. dynamic arrays</span> </div> </a> <ul id="toc-Linked_lists_vs._dynamic_arrays-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Singly_linked_linear_lists_vs._other_lists" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Singly_linked_linear_lists_vs._other_lists"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2</span> <span>Singly linked linear lists vs. other lists</span> </div> </a> <ul id="toc-Singly_linked_linear_lists_vs._other_lists-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Doubly_linked_vs._singly_linked" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Doubly_linked_vs._singly_linked"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.3</span> <span>Doubly linked vs. singly linked</span> </div> </a> <ul id="toc-Doubly_linked_vs._singly_linked-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Circularly_linked_vs._linearly_linked" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Circularly_linked_vs._linearly_linked"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.4</span> <span>Circularly linked vs. linearly linked</span> </div> </a> <ul id="toc-Circularly_linked_vs._linearly_linked-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Using_sentinel_nodes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Using_sentinel_nodes"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.5</span> <span>Using sentinel nodes</span> </div> </a> <ul id="toc-Using_sentinel_nodes-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Linked_list_operations" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Linked_list_operations"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Linked list operations</span> </div> </a> <button aria-controls="toc-Linked_list_operations-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Linked list operations subsection</span> </button> <ul id="toc-Linked_list_operations-sublist" class="vector-toc-list"> <li id="toc-Linearly_linked_lists" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Linearly_linked_lists"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>Linearly linked lists</span> </div> </a> <ul id="toc-Linearly_linked_lists-sublist" class="vector-toc-list"> <li id="toc-Singly_linked_lists" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Singly_linked_lists"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1.1</span> <span>Singly linked lists</span> </div> </a> <ul id="toc-Singly_linked_lists-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Circularly_linked_list" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Circularly_linked_list"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>Circularly linked list</span> </div> </a> <ul id="toc-Circularly_linked_list-sublist" class="vector-toc-list"> <li id="toc-Algorithms" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Algorithms"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2.1</span> <span>Algorithms</span> </div> </a> <ul id="toc-Algorithms-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Linked_lists_using_arrays_of_nodes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Linked_lists_using_arrays_of_nodes"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3</span> <span>Linked lists using arrays of nodes</span> </div> </a> <ul id="toc-Linked_lists_using_arrays_of_nodes-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Language_support" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Language_support"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Language support</span> </div> </a> <ul id="toc-Language_support-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Internal_and_external_storage" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Internal_and_external_storage"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Internal and external storage</span> </div> </a> <button aria-controls="toc-Internal_and_external_storage-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Internal and external storage subsection</span> </button> <ul id="toc-Internal_and_external_storage-sublist" class="vector-toc-list"> <li id="toc-Example_of_internal_and_external_storage" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Example_of_internal_and_external_storage"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.1</span> <span>Example of internal and external storage</span> </div> </a> <ul id="toc-Example_of_internal_and_external_storage-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Speeding_up_search" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Speeding_up_search"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.2</span> <span>Speeding up search</span> </div> </a> <ul id="toc-Speeding_up_search-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Random-access_lists" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Random-access_lists"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3</span> <span>Random-access lists</span> </div> </a> <ul id="toc-Random-access_lists-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Related_data_structures" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Related_data_structures"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>Related data structures</span> </div> </a> <ul id="toc-Related_data_structures-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Notes" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Notes"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>Notes</span> </div> </a> <ul id="toc-Notes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Further_reading" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Further_reading"> <div class="vector-toc-text"> <span class="vector-toc-numb">10</span> <span>Further reading</span> </div> </a> <ul id="toc-Further_reading-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">11</span> <span>External links</span> </div> </a> <ul id="toc-External_links-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" title="Table of Contents" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Linked list</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Go to an article in another language. Available in 44 languages" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-44" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">44 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-ar mw-list-item"><a href="https://ar.wikipedia.org/wiki/%D9%82%D8%A7%D8%A6%D9%85%D8%A9_%D9%85%D8%AA%D8%B5%D9%84%D8%A9" title="قائمة متصلة – Arabic" lang="ar" hreflang="ar" data-title="قائمة متصلة" data-language-autonym="العربية" data-language-local-name="Arabic" class="interlanguage-link-target"><span>العربية</span></a></li><li class="interlanguage-link interwiki-az mw-list-item"><a href="https://az.wikipedia.org/wiki/%C6%8Flaq%C9%99li_siyah%C4%B1" title="Əlaqəli siyahı – Azerbaijani" lang="az" hreflang="az" data-title="Əlaqəli siyahı" data-language-autonym="Azərbaycanca" data-language-local-name="Azerbaijani" class="interlanguage-link-target"><span>Azərbaycanca</span></a></li><li class="interlanguage-link interwiki-bn mw-list-item"><a href="https://bn.wikipedia.org/wiki/%E0%A6%B2%E0%A6%BF%E0%A6%99%E0%A7%8D%E0%A6%95%E0%A6%A1_%E0%A6%B2%E0%A6%BF%E0%A6%B8%E0%A7%8D%E0%A6%9F" title="লিঙ্কড লিস্ট – Bangla" lang="bn" hreflang="bn" data-title="লিঙ্কড লিস্ট" data-language-autonym="বাংলা" data-language-local-name="Bangla" class="interlanguage-link-target"><span>বাংলা</span></a></li><li class="interlanguage-link interwiki-zh-min-nan mw-list-item"><a href="https://zh-min-nan.wikipedia.org/wiki/Li%C3%A2n-kiat_list" title="Liân-kiat list – Minnan" lang="nan" hreflang="nan" data-title="Liân-kiat list" data-language-autonym="閩南語 / Bân-lâm-gú" data-language-local-name="Minnan" class="interlanguage-link-target"><span>閩南語 / Bân-lâm-gú</span></a></li><li class="interlanguage-link interwiki-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Llista_encadenada" title="Llista encadenada – Catalan" lang="ca" hreflang="ca" data-title="Llista encadenada" data-language-autonym="Català" data-language-local-name="Catalan" class="interlanguage-link-target"><span>Català</span></a></li><li class="interlanguage-link interwiki-cs mw-list-item"><a href="https://cs.wikipedia.org/wiki/Line%C3%A1rn%C3%AD_seznam" title="Lineární seznam – Czech" lang="cs" hreflang="cs" data-title="Lineární seznam" data-language-autonym="Čeština" data-language-local-name="Czech" class="interlanguage-link-target"><span>Čeština</span></a></li><li class="interlanguage-link interwiki-da mw-list-item"><a href="https://da.wikipedia.org/wiki/Liste_(datastruktur)" title="Liste (datastruktur) – Danish" lang="da" hreflang="da" data-title="Liste (datastruktur)" data-language-autonym="Dansk" data-language-local-name="Danish" class="interlanguage-link-target"><span>Dansk</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Liste_(Datenstruktur)" title="Liste (Datenstruktur) – German" lang="de" hreflang="de" data-title="Liste (Datenstruktur)" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-et mw-list-item"><a href="https://et.wikipedia.org/wiki/Ahelloend" title="Ahelloend – Estonian" lang="et" hreflang="et" data-title="Ahelloend" data-language-autonym="Eesti" data-language-local-name="Estonian" class="interlanguage-link-target"><span>Eesti</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Lista_enlazada" title="Lista enlazada – Spanish" lang="es" hreflang="es" data-title="Lista enlazada" data-language-autonym="Español" data-language-local-name="Spanish" class="interlanguage-link-target"><span>Español</span></a></li><li class="interlanguage-link interwiki-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%D9%84%DB%8C%D8%B3%D8%AA_%D9%BE%DB%8C%D9%88%D9%86%D8%AF%DB%8C" title="لیست پیوندی – Persian" lang="fa" hreflang="fa" data-title="لیست پیوندی" data-language-autonym="فارسی" data-language-local-name="Persian" class="interlanguage-link-target"><span>فارسی</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Liste_cha%C3%AEn%C3%A9e" title="Liste chaînée – French" lang="fr" hreflang="fr" data-title="Liste chaînée" data-language-autonym="Français" data-language-local-name="French" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%EC%97%B0%EA%B2%B0_%EB%A6%AC%EC%8A%A4%ED%8A%B8" title="연결 리스트 – Korean" lang="ko" hreflang="ko" data-title="연결 리스트" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-hr mw-list-item"><a href="https://hr.wikipedia.org/wiki/Vezana_lista" title="Vezana lista – Croatian" lang="hr" hreflang="hr" data-title="Vezana lista" data-language-autonym="Hrvatski" data-language-local-name="Croatian" class="interlanguage-link-target"><span>Hrvatski</span></a></li><li class="interlanguage-link interwiki-id mw-list-item"><a href="https://id.wikipedia.org/wiki/Senarai_berantai" title="Senarai berantai – Indonesian" lang="id" hreflang="id" data-title="Senarai berantai" data-language-autonym="Bahasa Indonesia" data-language-local-name="Indonesian" class="interlanguage-link-target"><span>Bahasa Indonesia</span></a></li><li class="interlanguage-link interwiki-is mw-list-item"><a href="https://is.wikipedia.org/wiki/Ke%C3%B0julisti" title="Keðjulisti – Icelandic" lang="is" hreflang="is" data-title="Keðjulisti" data-language-autonym="Íslenska" data-language-local-name="Icelandic" class="interlanguage-link-target"><span>Íslenska</span></a></li><li class="interlanguage-link interwiki-it mw-list-item"><a href="https://it.wikipedia.org/wiki/Lista_concatenata" title="Lista concatenata – Italian" lang="it" hreflang="it" data-title="Lista concatenata" data-language-autonym="Italiano" data-language-local-name="Italian" class="interlanguage-link-target"><span>Italiano</span></a></li><li class="interlanguage-link interwiki-he mw-list-item"><a href="https://he.wikipedia.org/wiki/%D7%A8%D7%A9%D7%99%D7%9E%D7%94_%D7%9E%D7%A7%D7%95%D7%A9%D7%A8%D7%AA" title="רשימה מקושרת – Hebrew" lang="he" hreflang="he" data-title="רשימה מקושרת" data-language-autonym="עברית" data-language-local-name="Hebrew" class="interlanguage-link-target"><span>עברית</span></a></li><li class="interlanguage-link interwiki-lv mw-list-item"><a href="https://lv.wikipedia.org/wiki/Saist%C4%ABts_saraksts" title="Saistīts saraksts – Latvian" lang="lv" hreflang="lv" data-title="Saistīts saraksts" data-language-autonym="Latviešu" data-language-local-name="Latvian" class="interlanguage-link-target"><span>Latviešu</span></a></li><li class="interlanguage-link interwiki-lt mw-list-item"><a href="https://lt.wikipedia.org/wiki/Tiesinis_s%C4%85ra%C5%A1as" title="Tiesinis sąrašas – Lithuanian" lang="lt" hreflang="lt" data-title="Tiesinis sąrašas" data-language-autonym="Lietuvių" data-language-local-name="Lithuanian" class="interlanguage-link-target"><span>Lietuvių</span></a></li><li class="interlanguage-link interwiki-lmo mw-list-item"><a href="https://lmo.wikipedia.org/wiki/Lista_concatenada" title="Lista concatenada – Lombard" lang="lmo" hreflang="lmo" data-title="Lista concatenada" data-language-autonym="Lombard" data-language-local-name="Lombard" class="interlanguage-link-target"><span>Lombard</span></a></li><li class="interlanguage-link interwiki-hu mw-list-item"><a href="https://hu.wikipedia.org/wiki/L%C3%A1ncolt_lista" title="Láncolt lista – Hungarian" lang="hu" hreflang="hu" data-title="Láncolt lista" data-language-autonym="Magyar" data-language-local-name="Hungarian" class="interlanguage-link-target"><span>Magyar</span></a></li><li class="interlanguage-link interwiki-ml mw-list-item"><a href="https://ml.wikipedia.org/wiki/%E0%B4%B2%E0%B4%BF%E0%B4%99%E0%B5%8D%E0%B4%95%E0%B5%8D%E0%B4%A1%E0%B5%8D_%E0%B4%B2%E0%B4%BF%E0%B4%B8%E0%B5%8D%E0%B4%B1%E0%B5%8D%E0%B4%B1%E0%B5%8D" title="ലിങ്ക്ഡ് ലിസ്റ്റ് – Malayalam" lang="ml" hreflang="ml" data-title="ലിങ്ക്ഡ് ലിസ്റ്റ്" data-language-autonym="മലയാളം" data-language-local-name="Malayalam" class="interlanguage-link-target"><span>മലയാളം</span></a></li><li class="interlanguage-link interwiki-ms mw-list-item"><a href="https://ms.wikipedia.org/wiki/Senarai_berpaut" title="Senarai berpaut – Malay" lang="ms" hreflang="ms" data-title="Senarai berpaut" data-language-autonym="Bahasa Melayu" data-language-local-name="Malay" class="interlanguage-link-target"><span>Bahasa Melayu</span></a></li><li class="interlanguage-link interwiki-mni mw-list-item"><a href="https://mni.wikipedia.org/wiki/%EA%AF%82%EA%AF%A4%EA%AF%89%EA%AF%AD%EA%AF%80_%EA%AF%82%EA%AF%A4%EA%AF%81" title="ꯂꯤꯉ꯭ꯀ ꯂꯤꯁ – Manipuri" lang="mni" hreflang="mni" data-title="ꯂꯤꯉ꯭ꯀ ꯂꯤꯁ" data-language-autonym="ꯃꯤꯇꯩ ꯂꯣꯟ" data-language-local-name="Manipuri" class="interlanguage-link-target"><span>ꯃꯤꯇꯩ ꯂꯣꯟ</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Gelinkte_lijst" title="Gelinkte lijst – Dutch" lang="nl" hreflang="nl" data-title="Gelinkte lijst" data-language-autonym="Nederlands" data-language-local-name="Dutch" class="interlanguage-link-target"><span>Nederlands</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/%E9%80%A3%E7%B5%90%E3%83%AA%E3%82%B9%E3%83%88" title="連結リスト – Japanese" lang="ja" hreflang="ja" data-title="連結リスト" data-language-autonym="日本語" data-language-local-name="Japanese" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-no mw-list-item"><a href="https://no.wikipedia.org/wiki/Lenket_liste" title="Lenket liste – Norwegian Bokmål" lang="nb" hreflang="nb" data-title="Lenket liste" data-language-autonym="Norsk bokmål" data-language-local-name="Norwegian Bokmål" class="interlanguage-link-target"><span>Norsk bokmål</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Lista" title="Lista – Polish" lang="pl" hreflang="pl" data-title="Lista" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Lista_ligada" title="Lista ligada – Portuguese" lang="pt" hreflang="pt" data-title="Lista ligada" data-language-autonym="Português" data-language-local-name="Portuguese" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/%D0%A1%D0%B2%D1%8F%D0%B7%D0%BD%D1%8B%D0%B9_%D1%81%D0%BF%D0%B8%D1%81%D0%BE%D0%BA" title="Связный список – Russian" lang="ru" hreflang="ru" data-title="Связный список" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-simple mw-list-item"><a href="https://simple.wikipedia.org/wiki/Linked_list" title="Linked list – Simple English" lang="en-simple" hreflang="en-simple" data-title="Linked list" data-language-autonym="Simple English" data-language-local-name="Simple English" class="interlanguage-link-target"><span>Simple English</span></a></li><li class="interlanguage-link interwiki-sl mw-list-item"><a href="https://sl.wikipedia.org/wiki/Povezani_seznam" title="Povezani seznam – Slovenian" lang="sl" hreflang="sl" data-title="Povezani seznam" data-language-autonym="Slovenščina" data-language-local-name="Slovenian" class="interlanguage-link-target"><span>Slovenščina</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/Povezana_lista" title="Povezana lista – Serbian" lang="sr" hreflang="sr" data-title="Povezana lista" data-language-autonym="Српски / srpski" data-language-local-name="Serbian" class="interlanguage-link-target"><span>Српски / srpski</span></a></li><li class="interlanguage-link interwiki-fi mw-list-item"><a href="https://fi.wikipedia.org/wiki/Linkitetty_lista" title="Linkitetty lista – Finnish" lang="fi" hreflang="fi" data-title="Linkitetty lista" data-language-autonym="Suomi" data-language-local-name="Finnish" class="interlanguage-link-target"><span>Suomi</span></a></li><li class="interlanguage-link interwiki-sv mw-list-item"><a href="https://sv.wikipedia.org/wiki/L%C3%A4nkad_lista" title="Länkad lista – Swedish" lang="sv" hreflang="sv" data-title="Länkad lista" data-language-autonym="Svenska" data-language-local-name="Swedish" class="interlanguage-link-target"><span>Svenska</span></a></li><li class="interlanguage-link interwiki-tl mw-list-item"><a href="https://tl.wikipedia.org/wiki/Listahang_pinagdugtong" title="Listahang pinagdugtong – Tagalog" lang="tl" hreflang="tl" data-title="Listahang pinagdugtong" data-language-autonym="Tagalog" data-language-local-name="Tagalog" class="interlanguage-link-target"><span>Tagalog</span></a></li><li class="interlanguage-link interwiki-th mw-list-item"><a href="https://th.wikipedia.org/wiki/%E0%B8%A3%E0%B8%B2%E0%B8%A2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%82%E0%B8%A2%E0%B8%87" title="รายการโยง – Thai" lang="th" hreflang="th" data-title="รายการโยง" data-language-autonym="ไทย" data-language-local-name="Thai" class="interlanguage-link-target"><span>ไทย</span></a></li><li class="interlanguage-link interwiki-tr mw-list-item"><a href="https://tr.wikipedia.org/wiki/Ba%C4%9Fl%C4%B1_liste" title="Bağlı liste – Turkish" lang="tr" hreflang="tr" data-title="Bağlı liste" data-language-autonym="Türkçe" data-language-local-name="Turkish" class="interlanguage-link-target"><span>Türkçe</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%97%D0%B2%27%D1%8F%D0%B7%D0%B0%D0%BD%D0%B8%D0%B9_%D1%81%D0%BF%D0%B8%D1%81%D0%BE%D0%BA" title="Зв'язаний список – Ukrainian" lang="uk" hreflang="uk" data-title="Зв'язаний список" data-language-autonym="Українська" data-language-local-name="Ukrainian" class="interlanguage-link-target"><span>Українська</span></a></li><li class="interlanguage-link interwiki-ur mw-list-item"><a href="https://ur.wikipedia.org/wiki/%D9%85%D9%86%D8%B3%D9%84%DA%A9_%D9%81%DB%81%D8%B1%D8%B3%D8%AA" title="منسلک فہرست – Urdu" lang="ur" hreflang="ur" data-title="منسلک فہرست" data-language-autonym="اردو" data-language-local-name="Urdu" class="interlanguage-link-target"><span>اردو</span></a></li><li class="interlanguage-link interwiki-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/Danh_s%C3%A1ch_li%C3%AAn_k%E1%BA%BFt" title="Danh sách liên kết – Vietnamese" lang="vi" hreflang="vi" data-title="Danh sách liên kết" data-language-autonym="Tiếng Việt" data-language-local-name="Vietnamese" class="interlanguage-link-target"><span>Tiếng Việt</span></a></li><li class="interlanguage-link interwiki-zh-yue mw-list-item"><a href="https://zh-yue.wikipedia.org/wiki/%E9%8F%88%E7%B5%90%E4%B8%B2%E5%88%97" title="鏈結串列 – Cantonese" lang="yue" hreflang="yue" data-title="鏈結串列" data-language-autonym="粵語" data-language-local-name="Cantonese" class="interlanguage-link-target"><span>粵語</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/%E9%93%BE%E8%A1%A8" title="链表 – Chinese" lang="zh" hreflang="zh" data-title="链表" data-language-autonym="中文" data-language-local-name="Chinese" class="interlanguage-link-target"><span>中文</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q7003418#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Linked_list" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Linked_list" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Linked_list"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Linked_list&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Linked_list&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Linked_list"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Linked_list&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Linked_list&action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Linked_list" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Linked_list" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Linked_list&oldid=1270124078" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Linked_list&action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&page=Linked_list&id=1270124078&wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLinked_list"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLinked_list"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&page=Linked_list&action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Linked_list&printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="wb-otherproject-link wb-otherproject-commons mw-list-item"><a href="https://commons.wikimedia.org/wiki/Category:Linked_lists" hreflang="en"><span>Wikimedia Commons</span></a></li><li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q7003418" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">Data structure with nodes pointing to the next node</div> <style data-mw-deduplicate="TemplateStyles:r1236090951">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}</style><div role="note" class="hatnote navigation-not-searchable">"Dynamic list" redirects here. For the Wikipedia guideline which describes list articles which may never be completed, see <a href="/wiki/Wikipedia:WikiProject_Lists" title="Wikipedia:WikiProject Lists">Wikipedia:WikiProject Lists</a>.</div> <style data-mw-deduplicate="TemplateStyles:r1251242444">.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}</style><table class="box-More_footnotes_needed plainlinks metadata ambox ambox-style ambox-More_footnotes_needed" role="presentation"><tbody><tr><td class="mbox-image"><div class="mbox-image-div"><span typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Text_document_with_red_question_mark.svg/40px-Text_document_with_red_question_mark.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Text_document_with_red_question_mark.svg/60px-Text_document_with_red_question_mark.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Text_document_with_red_question_mark.svg/80px-Text_document_with_red_question_mark.svg.png 2x" data-file-width="48" data-file-height="48" /></span></span></div></td><td class="mbox-text"><div class="mbox-text-span">This article includes a list of <a href="/wiki/Wikipedia:Citing_sources#General_references" title="Wikipedia:Citing sources">general references</a>, but <b>it lacks sufficient corresponding <a href="/wiki/Wikipedia:Citing_sources#Inline_citations" title="Wikipedia:Citing sources">inline citations</a></b>.<span class="hide-when-compact"> Please help to <a href="/wiki/Wikipedia:WikiProject_Reliability" title="Wikipedia:WikiProject Reliability">improve</a> this article by <a href="/wiki/Wikipedia:When_to_cite" title="Wikipedia:When to cite">introducing</a> more precise citations.</span> <span class="date-container"><i>(<span class="date">March 2012</span>)</i></span><span class="hide-when-compact"><i> (<small><a href="/wiki/Help:Maintenance_template_removal" title="Help:Maintenance template removal">Learn how and when to remove this message</a></small>)</i></span></div></td></tr></tbody></table> <figure typeof="mw:File/Frame"><a href="/wiki/File:Singly-linked-list.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Singly-linked-list.svg/408px-Singly-linked-list.svg.png" decoding="async" width="408" height="41" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Singly-linked-list.svg/612px-Singly-linked-list.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Singly-linked-list.svg/816px-Singly-linked-list.svg.png 2x" data-file-width="408" data-file-height="41" /></a><figcaption>A linked list is a sequence of nodes that contain two fields: data (an integer value here as an example) and a link to the next node. The last node is linked to a terminator used to signify the end of the list.</figcaption></figure> <p>In <a href="/wiki/Computer_science" title="Computer science">computer science</a>, a <b>linked list</b> is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element <a href="/wiki/Pointer_(computer_programming)" title="Pointer (computer programming)">points</a> to the next. It is a <a href="/wiki/Data_structure" title="Data structure">data structure</a> consisting of a collection of <a href="/wiki/Node_(computer_science)" title="Node (computer science)">nodes</a> which together represent a <a href="/wiki/Sequence" title="Sequence">sequence</a>. In its most basic form, each node contains <a href="/wiki/Data_(computing)" class="mw-redirect" title="Data (computing)">data</a>, and a <a href="/wiki/Reference_(computer_science)" title="Reference (computer science)">reference</a> (in other words, a <i>link</i>) to the next node in the sequence. This structure allows for efficient insertion or removal of elements from any position in the sequence during iteration. More complex variants add additional links, allowing more efficient insertion or removal of nodes at arbitrary positions. A drawback of linked lists is that data access time is <a href="/wiki/Time_complexity" title="Time complexity">linear</a> in respect to the number of nodes in the list. Because nodes are serially linked, accessing any node requires that the prior node be accessed beforehand (which introduces difficulties in <a href="/wiki/Instruction_pipelining" title="Instruction pipelining">pipelining</a>). Faster access, such as random access, is not feasible. <a href="/wiki/Array_data_structure" class="mw-redirect" title="Array data structure">Arrays</a> have better <a href="/wiki/Locality_of_reference" title="Locality of reference">cache locality</a> compared to linked lists. </p><p>Linked lists are among the simplest and most common data structures. They can be used to implement several other common <a href="/wiki/Abstract_data_type" title="Abstract data type">abstract data types</a>, including <a href="/wiki/List_(abstract_data_type)" title="List (abstract data type)">lists</a>, <a href="/wiki/Stack_(abstract_data_type)" title="Stack (abstract data type)">stacks</a>, <a href="/wiki/Queue_(abstract_data_type)" title="Queue (abstract data type)">queues</a>, <a href="/wiki/Associative_array" title="Associative array">associative arrays</a>, and <a href="/wiki/S-expression" title="S-expression">S-expressions</a>, though it is not uncommon to implement those data structures directly without using a linked list as the basis. </p><p>The principal benefit of a linked list over a conventional <a href="/wiki/Array_data_structure" class="mw-redirect" title="Array data structure">array</a> is that the list elements can be easily inserted or removed without reallocation or reorganization of the entire structure because the data items do not need to be stored <a href="https://en.wiktionary.org/wiki/contiguous" class="extiw" title="wikt:contiguous">contiguously</a> in memory or on disk, while restructuring an array at <a href="/wiki/Run_time_(program_lifecycle_phase)" class="mw-redirect" title="Run time (program lifecycle phase)">run-time</a> is a much more expensive operation. Linked lists allow insertion and removal of nodes at any point in the list, and allow doing so with a constant number of operations by keeping the link previous to the link being added or removed in memory during list traversal. </p><p>On the other hand, since simple linked lists by themselves do not allow <a href="/wiki/Random_access" title="Random access">random access</a> to the data or any form of efficient indexing, many basic operations—such as obtaining the last node of the list, finding a node that contains a given datum, or locating the place where a new node should be inserted—may require iterating through most or all of the list elements. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="History">History</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=1" title="Edit section: History"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Linked lists were developed in 1955–1956, by <a href="/wiki/Allen_Newell" title="Allen Newell">Allen Newell</a>, <a href="/wiki/Cliff_Shaw" title="Cliff Shaw">Cliff Shaw</a> and <a href="/wiki/Herbert_A._Simon" title="Herbert A. Simon">Herbert A. Simon</a> at <a href="/wiki/RAND_Corporation" title="RAND Corporation">RAND Corporation</a> and <a href="/wiki/Carnegie_Mellon_University" title="Carnegie Mellon University">Carnegie Mellon University</a> as the primary <a href="/wiki/Data_structure" title="Data structure">data structure</a> for their <a href="/wiki/Information_Processing_Language" title="Information Processing Language">Information Processing Language</a> (IPL). IPL was used by the authors to develop several early <a href="/wiki/Artificial_intelligence" title="Artificial intelligence">artificial intelligence</a> programs, including the Logic Theory Machine, the <a href="/wiki/General_Problem_Solver" title="General Problem Solver">General Problem Solver</a>, and a computer chess program. Reports on their work appeared in IRE Transactions on Information Theory in 1956, and several conference proceedings from 1957 to 1959, including Proceedings of the Western Joint Computer Conference in 1957 and 1958, and Information Processing (Proceedings of the first <a href="/wiki/UNESCO" title="UNESCO">UNESCO</a> International Conference on Information Processing) in 1959. The now-classic diagram consisting of blocks representing list nodes with arrows pointing to successive list nodes appears in "Programming the Logic Theory Machine" by Newell and Shaw in Proc. WJCC, February 1957. Newell and Simon were recognized with the ACM <a href="/wiki/Turing_Award" title="Turing Award">Turing Award</a> in 1975 for having "made basic contributions to artificial intelligence, the psychology of human cognition, and list processing". The problem of <a href="/wiki/Machine_translation" title="Machine translation">machine translation</a> for <a href="/wiki/Natural_language" title="Natural language">natural language</a> processing led <a href="/wiki/Victor_Yngve" title="Victor Yngve">Victor Yngve</a> at <a href="/wiki/Massachusetts_Institute_of_Technology" title="Massachusetts Institute of Technology">Massachusetts Institute of Technology</a> (MIT) to use linked lists as data structures in his COMIT programming language for computer research in the field of <a href="/wiki/Linguistics" title="Linguistics">linguistics</a>. A report on this language entitled "A programming language for mechanical translation" appeared in Mechanical Translation in 1958.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (January 2019)">citation needed</span></a></i>]</sup> </p><p>Another early appearance of linked lists was by <a href="/wiki/Hans_Peter_Luhn" title="Hans Peter Luhn">Hans Peter Luhn</a> who wrote an internal <a href="/wiki/IBM" title="IBM">IBM</a> memorandum in January 1953 that suggested the use of linked lists in chained hash tables.<sup id="cite_ref-knuth_1-0" class="reference"><a href="#cite_note-knuth-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> </p><p><a href="/wiki/LISP" class="mw-redirect" title="LISP">LISP</a>, standing for list processor, was created by <a href="/wiki/John_McCarthy_(computer_scientist)" title="John McCarthy (computer scientist)">John McCarthy</a> in 1958 while he was at MIT and in 1960 he published its design in a paper in the <a href="/wiki/Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a>, entitled "Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I". One of LISP's major data structures is the linked list. </p><p>By the early 1960s, the utility of both linked lists and languages which use these structures as their primary data representation was well established. Bert Green of the <a href="/wiki/MIT_Lincoln_Laboratory" title="MIT Lincoln Laboratory">MIT Lincoln Laboratory</a> published a review article entitled "Computer languages for symbol manipulation" in IRE Transactions on Human Factors in Electronics in March 1961 which summarized the advantages of the linked list approach. A later review article, "A Comparison of list-processing computer languages" by Bobrow and Raphael, appeared in Communications of the ACM in April 1964. </p><p>Several operating systems developed by <a href="/wiki/Technical_Systems_Consultants" title="Technical Systems Consultants">Technical Systems Consultants</a> (originally of West Lafayette Indiana, and later of Chapel Hill, North Carolina) used singly linked lists as file structures. A directory entry pointed to the first sector of a file, and succeeding portions of the file were located by traversing pointers. Systems using this technique included Flex (for the <a href="/wiki/Motorola_6800" title="Motorola 6800">Motorola 6800</a> CPU), mini-Flex (same CPU), and Flex9 (for the Motorola 6809 CPU). A variant developed by TSC for and marketed by <a href="/wiki/Smoke_Signal_Broadcasting" title="Smoke Signal Broadcasting">Smoke Signal Broadcasting</a> in California, used doubly linked lists in the same manner. </p><p>The TSS/360 operating system, developed by IBM for the System 360/370 machines, used a double linked list for their file system catalog. The directory structure was similar to Unix, where a directory could contain files and other directories and extend to any depth. </p> <div class="mw-heading mw-heading2"><h2 id="Basic_concepts_and_nomenclature">Basic concepts and nomenclature</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=2" title="Edit section: Basic concepts and nomenclature"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Each record of a linked list is often called an 'element' or '<a href="/wiki/Node_(computer_science)" title="Node (computer science)">node</a>'. </p><p>The field of each node that contains the address of the next node is usually called the 'next link' or 'next pointer'. The remaining fields are known as the 'data', 'information', 'value', 'cargo', or 'payload' fields. </p><p>The 'head' of a list is its first node. The 'tail' of a list may refer either to the rest of the list after the head, or to the last node in the list. In <a href="/wiki/Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a> and some derived languages, the next node may be called the '<a href="/wiki/CAR_and_CDR" title="CAR and CDR">cdr</a>' (pronounced <span class="IPA nowrap" lang="und-Latn-fonipa" title="Representation in the International Phonetic Alphabet (IPA)">/'kʊd.əɹ/</span>) of the list, while the payload of the head node may be called the 'car'. </p> <div class="mw-heading mw-heading3"><h3 id="Singly_linked_list">Singly linked list</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=3" title="Edit section: Singly linked list"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Singly linked lists contain nodes which have a 'value' field as well as 'next' field, which points to the next node in line of nodes. Operations that can be performed on singly linked lists include insertion, deletion and traversal. </p> <figure class="mw-halign-center" typeof="mw:File/Frame"><a href="/wiki/File:Singly-linked-list.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Singly-linked-list.svg/408px-Singly-linked-list.svg.png" decoding="async" width="408" height="41" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Singly-linked-list.svg/612px-Singly-linked-list.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Singly-linked-list.svg/816px-Singly-linked-list.svg.png 2x" data-file-width="408" data-file-height="41" /></a><figcaption>A singly linked list whose nodes contain two fields: an integer value (data) and a link to the next node</figcaption></figure><p> The following C language code demonstrates how to add a new node with the "value" to the end of a singly linked list:</p><div class="mw-highlight mw-highlight-lang-c mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span></span><span class="linenos" data-line="1"></span><span class="c1">// Each node in a linked list is a structure. The head node is the first node in the list.</span> <span class="linenos" data-line="2"></span> <span class="linenos" data-line="3"></span><span class="n">Node</span><span class="w"> </span><span class="o">*</span><span class="nf">addNodeToTail</span><span class="p">(</span><span class="n">Node</span><span class="w"> </span><span class="o">*</span><span class="n">head</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">value</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="4"></span><span class="w"> </span><span class="c1">// declare Node pointer and initialize to point to the new Node (i.e., it will have the new Node's memory address) being added to the end of the list.</span> <span class="linenos" data-line="5"></span><span class="w"> </span><span class="n">Node</span><span class="w"> </span><span class="o">*</span><span class="n">temp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">malloc</span><span class="p">(</span><span class="k">sizeof</span><span class="w"> </span><span class="o">*</span><span class="n">temp</span><span class="p">);</span><span class="w"> </span><span class="c1">/// 'malloc' in stdlib.</span> <span class="linenos" data-line="6"></span><span class="w"> </span><span class="n">temp</span><span class="o">-></span><span class="n">value</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">value</span><span class="p">;</span><span class="w"> </span><span class="c1">// Add data to the value field of the new Node.</span> <span class="linenos" data-line="7"></span><span class="w"> </span><span class="n">temp</span><span class="o">-></span><span class="n">next</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">;</span><span class="w"> </span><span class="c1">// initialize invalid links to nil.</span> <span class="linenos" data-line="8"></span><span class="w"> </span> <span class="linenos" data-line="9"></span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">head</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="10"></span><span class="w"> </span><span class="n">head</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">temp</span><span class="p">;</span><span class="w"> </span><span class="c1">// If the linked list is empty (i.e., the head node pointer is a null pointer), then have the head node pointer point to the new Node.</span> <span class="linenos" data-line="11"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="12"></span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="13"></span><span class="w"> </span><span class="n">Node</span><span class="w"> </span><span class="o">*</span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">head</span><span class="p">;</span><span class="w"> </span><span class="c1">// Assign the head node pointer to the Node pointer 'p'.</span> <span class="linenos" data-line="14"></span><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">p</span><span class="o">-></span><span class="n">next</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="linenos" data-line="15"></span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="o">-></span><span class="n">next</span><span class="p">;</span><span class="w"> </span><span class="c1">// Traverse the list until p is the last Node. The last Node always points to NULL.</span> <span class="linenos" data-line="16"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="17"></span><span class="w"> </span><span class="n">p</span><span class="o">-></span><span class="n">next</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">temp</span><span class="p">;</span><span class="w"> </span><span class="c1">// Make the previously last Node point to the new Node.</span> <span class="linenos" data-line="18"></span><span class="w"> </span><span class="p">}</span> <span class="linenos" data-line="19"></span><span class="w"> </span> <span class="linenos" data-line="20"></span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">head</span><span class="p">;</span><span class="w"> </span><span class="c1">// Return the head node pointer.</span> <span class="linenos" data-line="21"></span><span class="p">}</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Doubly_linked_list">Doubly linked list</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=4" title="Edit section: Doubly linked list"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Doubly_linked_list" title="Doubly linked list">Doubly linked list</a></div> <p>In a 'doubly linked list', each node contains, besides the next-node link, a second link field pointing to the 'previous' node in the sequence. The two links may be called 'forward('s') and 'backwards', or 'next' and 'prev'('previous'). </p> <figure class="mw-halign-center" typeof="mw:File/Frame"><a href="/wiki/File:Doubly-linked-list.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Doubly-linked-list.svg/610px-Doubly-linked-list.svg.png" decoding="async" width="610" height="41" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Doubly-linked-list.svg/915px-Doubly-linked-list.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Doubly-linked-list.svg/1220px-Doubly-linked-list.svg.png 2x" data-file-width="610" data-file-height="41" /></a><figcaption>A doubly linked list whose nodes contain three fields: an integer value, the link forward to the next node, and the link backward to the previous node</figcaption></figure> <p>A technique known as <a href="/wiki/XOR_linked_list" title="XOR linked list">XOR-linking</a> allows a doubly linked list to be implemented using a single link field in each node. However, this technique requires the ability to do bit operations on addresses, and therefore may not be available in some high-level languages. </p><p>Many modern operating systems use doubly linked lists to maintain references to active processes, threads, and other dynamic objects.<sup id="cite_ref-:0_2-0" class="reference"><a href="#cite_note-:0-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> A common strategy for <a href="/wiki/Rootkits" class="mw-redirect" title="Rootkits">rootkits</a> to evade detection is to unlink themselves from these lists.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading3"><h3 id="Multiply_linked_list">Multiply linked list</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=5" title="Edit section: Multiply linked list"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In a 'multiply linked list', each node contains two or more link fields, each field being used to connect the same set of data arranged in a different order (e.g., by name, by department, by date of birth, etc.). While a doubly linked list can be seen as a special case of multiply linked list, the fact that the two and more orders are opposite to each other leads to simpler and more efficient algorithms, so they are usually treated as a separate case. </p> <div class="mw-heading mw-heading3"><h3 id="Circular_linked_list">Circular linked list</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=6" title="Edit section: Circular linked list"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the last node of a linked list, the link field often contains a <a href="/wiki/Null_pointer#Null_pointer" title="Null pointer">null</a> reference, a special value is used to indicate the lack of further nodes. A less common convention is to make it point to the first node of the list; in that case, the list is said to be 'circular' or 'circularly linked'; otherwise, it is said to be 'open' or 'linear'. It is a <a href="/wiki/List" title="List">list</a> where the last node pointer points to the first node (i.e., the "next link" pointer of the last node has the memory address of the first node). </p> <figure class="mw-halign-center" typeof="mw:File/Frame"><a href="/wiki/File:Circularly-linked-list.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Circularly-linked-list.svg/350px-Circularly-linked-list.svg.png" decoding="async" width="350" height="60" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Circularly-linked-list.svg/525px-Circularly-linked-list.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/df/Circularly-linked-list.svg/700px-Circularly-linked-list.svg.png 2x" data-file-width="350" data-file-height="60" /></a><figcaption>A circular linked list</figcaption></figure> <p>In the case of a circular doubly linked list, the first node also points to the last node of the list. </p> <div class="mw-heading mw-heading3"><h3 id="Sentinel_nodes">Sentinel nodes</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=7" title="Edit section: Sentinel nodes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951" /><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Sentinel_node" title="Sentinel node">Sentinel node</a></div> <p>In some implementations an extra 'sentinel' or 'dummy' node may be added before the first data record or after the last one. This convention simplifies and accelerates some list-handling algorithms, by ensuring that all links can be safely dereferenced and that every list (even one that contains no data elements) always has a "first" and "last" node. </p> <div class="mw-heading mw-heading3"><h3 id="Empty_lists">Empty lists</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=8" title="Edit section: Empty lists"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>An empty list is a list that contains no data records. This is usually the same as saying that it has zero nodes. If sentinel nodes are being used, the list is usually said to be empty when it has only sentinel nodes. </p> <div class="mw-heading mw-heading3"><h3 id="Hash_linking">Hash linking</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=9" title="Edit section: Hash linking"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The link fields need not be physically part of the nodes. If the data records are stored in an array and referenced by their indices, the link field may be stored in a separate array with the same indices as the data records. </p> <div class="mw-heading mw-heading3"><h3 id="List_handles">List handles</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=10" title="Edit section: List handles"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Since a reference to the first node gives access to the whole list, that reference is often called the 'address', 'pointer', or 'handle' of the list. Algorithms that manipulate linked lists usually get such handles to the input lists and return the handles to the resulting lists. In fact, in the context of such algorithms, the word "list" often means "list handle". In some situations, however, it may be convenient to refer to a list by a handle that consists of two links, pointing to its first and last nodes. </p> <div class="mw-heading mw-heading3"><h3 id="Combining_alternatives">Combining alternatives</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=11" title="Edit section: Combining alternatives"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The alternatives listed above may be arbitrarily combined in almost every way, so one may have circular doubly linked lists without sentinels, circular singly linked lists with sentinels, etc. </p> <div class="mw-heading mw-heading2"><h2 id="Tradeoffs">Tradeoffs</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=12" title="Edit section: Tradeoffs"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>As with most choices in computer programming and design, no method is well suited to all circumstances. A linked list data structure might work well in one case, but cause problems in another. This is a list of some of the common tradeoffs involving linked list structures. </p> <div class="mw-heading mw-heading3"><h3 id="Linked_lists_vs._dynamic_arrays">Linked lists vs. dynamic arrays</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=13" title="Edit section: Linked lists vs. dynamic arrays"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <table class="wikitable"> <caption>Comparison of list data structures </caption> <tbody><tr> <th rowspan="2"> </th> <th rowspan="2">Peek <br />(index) </th> <th colspan="3">Mutate (insert or delete) at … </th> <th rowspan="2">Excess space, <br />average </th></tr> <tr> <th>Beginning </th> <th>End </th> <th>Middle </th></tr> <tr> <td><a class="mw-selflink selflink">Linked list</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1), known end element;<br />Θ(<i>n</i>), unknown end element </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td></tr> <tr> <td><a href="/wiki/Array_data_structure" class="mw-redirect" title="Array data structure">Array</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) </td> <td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">— </td> <td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">— </td> <td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">— </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">0 </td></tr> <tr> <td><a href="/wiki/Dynamic_array" title="Dynamic array">Dynamic array</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) <a href="/wiki/Amortized_analysis" title="Amortized analysis">amortized</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td><a href="/wiki/Self-balancing_binary_search_tree" title="Self-balancing binary search tree">Balanced tree</a> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log n) </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log n) </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log <i>n</i>) </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log <i>n</i>) </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td></tr> <tr> <td>Random-<span class="nowrap">access list</span> </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log n)<sup id="cite_ref-okasakiComparison_5-0" class="reference"><a href="#cite_note-okasakiComparison-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) </td> <td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">—<sup id="cite_ref-okasakiComparison_5-1" class="reference"><a href="#cite_note-okasakiComparison-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> </td> <td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">—<sup id="cite_ref-okasakiComparison_5-2" class="reference"><a href="#cite_note-okasakiComparison-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td></tr> <tr> <td><a href="/wiki/Hashed_array_tree" title="Hashed array tree">Hashed array tree</a> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) <a href="/wiki/Amortized_analysis" title="Amortized analysis">amortized</a> </td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>) </td> <td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(√<i>n</i>) </td></tr></tbody></table> <p>A <i><a href="/wiki/Dynamic_array" title="Dynamic array">dynamic array</a></i> is a data structure that allocates all elements contiguously in memory, and keeps a count of the current number of elements. If the space reserved for the dynamic array is exceeded, it is reallocated and (possibly) copied, which is an expensive operation. </p><p>Linked lists have several advantages over dynamic arrays. Insertion or deletion of an element at a specific point of a list, assuming that a pointer is indexed to the node (before the one to be removed, or before the insertion point) already, is a constant-time operation (otherwise without this reference it is O(n)), whereas insertion in a dynamic array at random locations will require moving half of the elements on average, and all the elements in the worst case. While one can "delete" an element from an array in constant time by somehow marking its slot as "vacant", this causes <a href="/wiki/Fragmentation_(computer)" class="mw-redirect" title="Fragmentation (computer)">fragmentation</a> that impedes the performance of iteration. </p><p>Moreover, arbitrarily many elements may be inserted into a linked list, limited only by the total memory available; while a dynamic array will eventually fill up its underlying array data structure and will have to reallocate—an expensive operation, one that may not even be possible if memory is fragmented, although the cost of reallocation can be averaged over insertions, and the cost of an insertion due to reallocation would still be <a href="/wiki/Amortized_analysis" title="Amortized analysis">amortized</a> O(1). This helps with appending elements at the array's end, but inserting into (or removing from) middle positions still carries prohibitive costs due to data moving to maintain contiguity. An array from which many elements are removed may also have to be resized in order to avoid wasting too much space. </p><p>On the other hand, dynamic arrays (as well as fixed-size <a href="/wiki/Array_data_structure" class="mw-redirect" title="Array data structure">array data structures</a>) allow constant-time <a href="/wiki/Random_access" title="Random access">random access</a>, while linked lists allow only <a href="/wiki/Sequential_access" title="Sequential access">sequential access</a> to elements. Singly linked lists, in fact, can be easily traversed in only one direction. This makes linked lists unsuitable for applications where it's useful to look up an element by its index quickly, such as <a href="/wiki/Heapsort" title="Heapsort">heapsort</a>. Sequential access on arrays and dynamic arrays is also faster than on linked lists on many machines, because they have optimal <a href="/wiki/Locality_of_reference" title="Locality of reference">locality of reference</a> and thus make good use of data caching. </p><p>Another disadvantage of linked lists is the extra storage needed for references, which often makes them impractical for lists of small data items such as <a href="/wiki/Character_(computing)" title="Character (computing)">characters</a> or <a href="/wiki/Boolean_value" class="mw-redirect" title="Boolean value">Boolean values</a>, because the storage overhead for the links may exceed by a factor of two or more the size of the data. In contrast, a dynamic array requires only the space for the data itself (and a very small amount of control data).<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>note 1<span class="cite-bracket">]</span></a></sup> It can also be slow, and with a naïve allocator, wasteful, to allocate memory separately for each new element, a problem generally solved using <a href="/wiki/Memory_pool" title="Memory pool">memory pools</a>. </p><p>Some hybrid solutions try to combine the advantages of the two representations. <a href="/wiki/Unrolled_linked_list" title="Unrolled linked list">Unrolled linked lists</a> store several elements in each list node, increasing cache performance while decreasing memory overhead for references. <a href="/wiki/CDR_coding" title="CDR coding">CDR coding</a> does both these as well, by replacing references with the actual data referenced, which extends off the end of the referencing record. </p><p>A good example that highlights the pros and cons of using dynamic arrays vs. linked lists is by implementing a program that resolves the <a href="/wiki/Josephus_problem" title="Josephus problem">Josephus problem</a>. The Josephus problem is an election method that works by having a group of people stand in a circle. Starting at a predetermined person, one may count around the circle <i>n</i> times. Once the <i>n</i>th person is reached, one should remove them from the circle and have the members close the circle. The process is repeated until only one person is left. That person wins the election. This shows the strengths and weaknesses of a linked list vs. a dynamic array, because if the people are viewed as connected nodes in a circular linked list, then it shows how easily the linked list is able to delete nodes (as it only has to rearrange the links to the different nodes). However, the linked list will be poor at finding the next person to remove and will need to search through the list until it finds that person. A dynamic array, on the other hand, will be poor at deleting nodes (or elements) as it cannot remove one node without individually shifting all the elements up the list by one. However, it is exceptionally easy to find the <i>n</i>th person in the circle by directly referencing them by their position in the array. </p><p>The <a href="/wiki/List_ranking" title="List ranking">list ranking</a> problem concerns the efficient conversion of a linked list representation into an array. Although trivial for a conventional computer, solving this problem by a <a href="/wiki/Parallel_algorithm" title="Parallel algorithm">parallel algorithm</a> is complicated and has been the subject of much research. </p><p>A <a href="/wiki/Self-balancing_binary_search_tree" title="Self-balancing binary search tree">balanced tree</a> has similar memory access patterns and space overhead to a linked list while permitting much more efficient indexing, taking O(log n) time instead of O(n) for a random access. However, insertion and deletion operations are more expensive due to the overhead of tree manipulations to maintain balance. Schemes exist for trees to automatically maintain themselves in a balanced state: <a href="/wiki/AVL_tree" title="AVL tree">AVL trees</a> or <a href="/wiki/Red%E2%80%93black_tree" title="Red–black tree">red–black trees</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Singly_linked_linear_lists_vs._other_lists">Singly linked linear lists vs. other lists</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=14" title="Edit section: Singly linked linear lists vs. other lists"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>While doubly linked and circular lists have advantages over singly linked linear lists, linear lists offer some advantages that make them preferable in some situations. </p><p>A singly linked linear list is a <a href="/wiki/Recursion" title="Recursion">recursive</a> data structure, because it contains a pointer to a <i>smaller</i> object of the same type. For that reason, many operations on singly linked linear lists (such as <a href="/wiki/Merge_algorithm" title="Merge algorithm">merging</a> two lists, or enumerating the elements in reverse order) often have very simple recursive algorithms, much simpler than any solution using <a href="/wiki/Iteration" title="Iteration">iterative commands</a>. While those recursive solutions can be adapted for doubly linked and circularly linked lists, the procedures generally need extra arguments and more complicated base cases. </p><p>Linear singly linked lists also allow <a href="/wiki/Tail-sharing" class="mw-redirect" title="Tail-sharing">tail-sharing</a>, the use of a common final portion of sub-list as the terminal portion of two different lists. In particular, if a new node is added at the beginning of a list, the former list remains available as the tail of the new one—a simple example of a <a href="/wiki/Persistent_data_structure" title="Persistent data structure">persistent data structure</a>. Again, this is not true with the other variants: a node may never belong to two different circular or doubly linked lists. </p><p>In particular, end-sentinel nodes can be shared among singly linked non-circular lists. The same end-sentinel node may be used for <i>every</i> such list. In <a href="/wiki/Lisp_programming_language" class="mw-redirect" title="Lisp programming language">Lisp</a>, for example, every proper list ends with a link to a special node, denoted by <code>nil</code> or <code>()</code>. </p><p>The advantages of the fancy variants are often limited to the complexity of the algorithms, not in their efficiency. A circular list, in particular, can usually be emulated by a linear list together with two variables that point to the first and last nodes, at no extra cost. </p> <div class="mw-heading mw-heading3"><h3 id="Doubly_linked_vs._singly_linked">Doubly linked vs. singly linked</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=15" title="Edit section: Doubly linked vs. singly linked"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Double-linked lists require more space per node (unless one uses <a href="/wiki/XOR_linked_list" title="XOR linked list">XOR-linking</a>), and their elementary operations are more expensive; but they are often easier to manipulate because they allow fast and easy sequential access to the list in both directions. In a doubly linked list, one can insert or delete a node in a constant number of operations given only that node's address. To do the same in a singly linked list, one must have the <i>address of the pointer</i> to that node, which is either the handle for the whole list (in case of the first node) or the link field in the <i>previous</i> node. Some algorithms require access in both directions. On the other hand, doubly linked lists do not allow tail-sharing and cannot be used as <a href="/wiki/Persistent_data_structure" title="Persistent data structure">persistent data structures</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Circularly_linked_vs._linearly_linked">Circularly linked vs. linearly linked</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=16" title="Edit section: Circularly linked vs. linearly linked"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A circularly linked list may be a natural option to represent arrays that are naturally circular, e.g. the corners of a <a href="/wiki/Polygon" title="Polygon">polygon</a>, a pool of <a href="/wiki/Data_buffer" title="Data buffer">buffers</a> that are used and released in <a href="/wiki/FIFO_(computing_and_electronics)" title="FIFO (computing and electronics)">FIFO</a> ("first in, first out") order, or a set of processes that should be <a href="/wiki/Time_sharing" class="mw-redirect" title="Time sharing">time-shared</a> in <a href="/wiki/Round-robin_scheduling" title="Round-robin scheduling">round-robin order</a>. In these applications, a pointer to any node serves as a handle to the whole list. </p><p>With a circular list, a pointer to the last node gives easy access also to the first node, by following one link. Thus, in applications that require access to both ends of the list (e.g., in the implementation of a queue), a circular structure allows one to handle the structure by a single pointer, instead of two. </p><p>A circular list can be split into two circular lists, in constant time, by giving the addresses of the last node of each piece. The operation consists in swapping the contents of the link fields of those two nodes. Applying the same operation to any two nodes in two distinct lists joins the two list into one. This property greatly simplifies some algorithms and data structures, such as the <a href="/wiki/Quad-edge_data_structure" class="mw-redirect" title="Quad-edge data structure">quad-edge</a> and <a href="/w/index.php?title=Face-edge_data_structure&action=edit&redlink=1" class="new" title="Face-edge data structure (page does not exist)">face-edge</a>. </p><p>The simplest representation for an empty <i>circular</i> list (when such a thing makes sense) is a null pointer, indicating that the list has no nodes. Without this choice, many algorithms have to test for this special case, and handle it separately. By contrast, the use of null to denote an empty <i>linear</i> list is more natural and often creates fewer special cases. </p><p>For some applications, it can be useful to use singly linked lists that can vary between being circular and being linear, or even circular with a linear initial segment. Algorithms for searching or otherwise operating on these have to take precautions to avoid accidentally entering an endless loop. One <a href="/wiki/Cycle_detection" title="Cycle detection">well-known method</a> is to have a second pointer walking the list at half or double the speed, and if both pointers meet at the same node, a cycle has been found. </p> <div class="mw-heading mw-heading3"><h3 id="Using_sentinel_nodes">Using sentinel nodes</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=17" title="Edit section: Using sentinel nodes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Sentinel_node" title="Sentinel node">Sentinel node</a> may simplify certain list operations, by ensuring that the next or previous nodes exist for every element, and that even empty lists have at least one node. One may also use a sentinel node at the end of the list, with an appropriate data field, to eliminate some end-of-list tests. For example, when scanning the list looking for a node with a given value <i>x</i>, setting the sentinel's data field to <i>x</i> makes it unnecessary to test for end-of-list inside the loop. Another example is the merging two sorted lists: if their sentinels have data fields set to +∞, the choice of the next output node does not need special handling for empty lists. </p><p>However, sentinel nodes use up extra space (especially in applications that use many short lists), and they may complicate other operations (such as the creation of a new empty list). </p><p>However, if the circular list is used merely to simulate a linear list, one may avoid some of this complexity by adding a single sentinel node to every list, between the last and the first data nodes. With this convention, an empty list consists of the sentinel node alone, pointing to itself via the next-node link. The list handle should then be a pointer to the last data node, before the sentinel, if the list is not empty; or to the sentinel itself, if the list is empty. </p><p>The same trick can be used to simplify the handling of a doubly linked linear list, by turning it into a circular doubly linked list with a single sentinel node. However, in this case, the handle should be a single pointer to the dummy node itself.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Linked_list_operations">Linked list operations</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=18" title="Edit section: Linked list operations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>When manipulating linked lists in-place, care must be taken to not use values that have been invalidated in previous assignments. This makes algorithms for inserting or deleting linked list nodes somewhat subtle. This section gives <a href="/wiki/Pseudocode" title="Pseudocode">pseudocode</a> for adding or removing nodes from singly, doubly, and circularly linked lists in-place. Throughout, <i>null</i> is used to refer to an end-of-list marker or <a href="/wiki/Sentinel_value" title="Sentinel value">sentinel</a>, which may be implemented in a number of ways. </p> <div class="mw-heading mw-heading3"><h3 id="Linearly_linked_lists">Linearly linked lists</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=19" title="Edit section: Linearly linked lists"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading4"><h4 id="Singly_linked_lists">Singly linked lists</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=20" title="Edit section: Singly linked lists"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The node data structure will have two fields. There is also a variable, <i>firstNode</i> which always points to the first node in the list, or is <i>null</i> for an empty list. </p> <pre><b>record</b> <i>Node</i> { data; <i>// The data being stored in the node</i> <i>Node</i> next <i>// A <a href="/wiki/Reference_(computer_science)" title="Reference (computer science)">reference</a></i><sup id="cite_ref-:0_2-1" class="reference"><a href="#cite_note-:0-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> to the next node, null for last node } </pre> <pre><b>record</b> <i>List</i> { <i>Node</i> firstNode <i>// points to first node of list; null for empty list</i> } </pre> <p>Traversal of a singly linked list is simple, beginning at the first node and following each <i>next</i> link until reaching the end: </p> <pre>node := list.firstNode <b>while</b> node not null <i>(do something with node.data)</i> node := node.next </pre> <p>The following code inserts a node after an existing node in a singly linked list. The diagram shows how it works. Inserting a node before an existing one cannot be done directly; instead, one must keep track of the previous node and insert a node after it. </p> <figure class="mw-halign-center" typeof="mw:File/Frame"><a href="/wiki/File:CPT-LinkedLists-addingnode.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/4/4b/CPT-LinkedLists-addingnode.svg/474px-CPT-LinkedLists-addingnode.svg.png" decoding="async" width="474" height="116" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/4/4b/CPT-LinkedLists-addingnode.svg/711px-CPT-LinkedLists-addingnode.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/4/4b/CPT-LinkedLists-addingnode.svg/948px-CPT-LinkedLists-addingnode.svg.png 2x" data-file-width="474" data-file-height="116" /></a><figcaption>Diagram of inserting a node into a singly linked list</figcaption></figure> <pre><b>function</b> insertAfter(<i>Node</i> node, <i>Node</i> newNode) <i>// insert newNode after node</i> newNode.next := node.next node.next  := newNode </pre> <p>Inserting at the beginning of the list requires a separate function. This requires updating <i>firstNode</i>. </p> <pre><b>function</b> insertBeginning(<i>List</i> list, <i>Node</i> newNode) <i>// insert node before current first node</i> newNode.next  := list.firstNode list.firstNode := newNode </pre> <p>Similarly, there are functions for removing the node <i>after</i> a given node, and for removing a node from the beginning of the list. The diagram demonstrates the former. To find and remove a particular node, one must again keep track of the previous element. </p> <figure class="mw-halign-center" typeof="mw:File/Frame"><a href="/wiki/File:CPT-LinkedLists-deletingnode.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d4/CPT-LinkedLists-deletingnode.svg/380px-CPT-LinkedLists-deletingnode.svg.png" decoding="async" width="380" height="174" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d4/CPT-LinkedLists-deletingnode.svg/570px-CPT-LinkedLists-deletingnode.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d4/CPT-LinkedLists-deletingnode.svg/760px-CPT-LinkedLists-deletingnode.svg.png 2x" data-file-width="380" data-file-height="174" /></a><figcaption>Diagram of deleting a node from a singly linked list</figcaption></figure> <pre><b>function</b> removeAfter(<i>Node</i> node) <i>// remove node past this one</i> obsoleteNode := node.next node.next := node.next.next destroy obsoleteNode </pre> <pre><b>function</b> removeBeginning(<i>List</i> list) <i>// remove first node</i> obsoleteNode := list.firstNode list.firstNode := list.firstNode.next <i>// point past deleted node</i> destroy obsoleteNode </pre> <p>Notice that <code>removeBeginning()</code> sets <code>list.firstNode</code> to <code>null</code> when removing the last node in the list. </p><p>Since it is not possible to iterate backwards, efficient <code>insertBefore</code> or <code>removeBefore</code> operations are not possible. Inserting to a list before a specific node requires traversing the list, which would have a worst case running time of O(n). </p><p>Appending one linked list to another can be inefficient unless a reference to the tail is kept as part of the List structure, because it is needed to traverse the entire first list in order to find the tail, and then append the second list to this. Thus, if two linearly linked lists are each of length <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>n</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle n}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a601995d55609f2d9f5e233e36fbe9ea26011b3b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.395ex; height:1.676ex;" alt="{\displaystyle n}" /></span>, list appending has <a href="/wiki/Asymptotic_time_complexity" class="mw-redirect" title="Asymptotic time complexity">asymptotic time complexity</a> of <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n)}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>O</mi> <mo stretchy="false">(</mo> <mi>n</mi> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle O(n)}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/34109fe397fdcff370079185bfdb65826cb5565a" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:4.977ex; height:2.843ex;" alt="{\displaystyle O(n)}" /></span>. In the Lisp family of languages, list appending is provided by the <code><a href="/wiki/Append" title="Append">append</a></code> procedure. </p><p>Many of the special cases of linked list operations can be eliminated by including a dummy element at the front of the list. This ensures that there are no special cases for the beginning of the list and renders both <code>insertBeginning()</code> and <code>removeBeginning()</code> unnecessary, i.e., every element or node is next to another node (even the first node is next to the dummy node). In this case, the first useful data in the list will be found at <code>list.<b>firstNode</b>.next</code>. </p> <div class="mw-heading mw-heading3"><h3 id="Circularly_linked_list">Circularly linked list</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=21" title="Edit section: Circularly linked list"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In a circularly linked list, all nodes are linked in a continuous circle, without using <i>null.</i> For lists with a front and a back (such as a queue), one stores a reference to the last node in the list. The <i>next</i> node after the last node is the first node. Elements can be added to the back of the list and removed from the front in constant time. </p><p>Circularly linked lists can be either singly or doubly linked. </p><p>Both types of circularly linked lists benefit from the ability to traverse the full list beginning at any given node. This often allows us to avoid storing <i>firstNode</i> and <i>lastNode</i>, although if the list may be empty, there needs to be a special representation for the empty list, such as a <i>lastNode</i> variable which points to some node in the list or is <i>null</i> if it is empty; it uses such a <i>lastNode</i> here. This representation significantly simplifies adding and removing nodes with a non-empty list, but empty lists are then a special case. </p> <div class="mw-heading mw-heading4"><h4 id="Algorithms">Algorithms</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=22" title="Edit section: Algorithms"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Assuming that <i>someNode</i> is some node in a non-empty circular singly linked list, this code iterates through that list starting with <i>someNode</i>: </p> <pre><b>function</b> iterate(someNode) <b>if</b> someNode ≠ <b>null</b> node := someNode <b>do</b> do something with node.value node := node.next <b>while</b> node ≠ someNode </pre> <p>Notice that the test "<b>while</b> node ≠ someNode" must be at the end of the loop. If the test was moved to the beginning of the loop, the procedure would fail whenever the list had only one node. </p><p>This function inserts a node "newNode" into a circular linked list after a given node "node". If "node" is null, it assumes that the list is empty. </p> <pre><b>function</b> insertAfter(<i>Node</i> node, <i>Node</i> newNode) <b>if</b> node = <b>null</b> // assume list is empty newNode.next := newNode <b>else</b> newNode.next := node.next node.next := newNode update <i>lastNode</i> variable if necessary </pre> <p>Suppose that "L" is a variable pointing to the last node of a circular linked list (or null if the list is empty). To append "newNode" to the <i>end</i> of the list, one may do </p> <pre>insertAfter(L, newNode) L := newNode </pre> <p>To insert "newNode" at the <i>beginning</i> of the list, one may do </p> <pre>insertAfter(L, newNode) <b>if</b> L = <b>null</b> L := newNode </pre> <p>This function inserts a value "newVal" before a given node "node" in O(1) time. A new node has been created between "node" and the next node, then puts the value of "node" into that new node, and puts "newVal" in "node". Thus, a singly linked circularly linked list with only a <i>firstNode</i> variable can both insert to the front and back in O(1) time. </p> <pre><b>function</b> insertBefore(<i>Node</i> node, newVal) <b>if</b> node = <b>null</b> // assume list is empty newNode := <b>new</b> Node(data:=newVal, next:=newNode) <b>else</b> newNode := <b>new</b> Node(data:=node.data, next:=node.next) node.data := newVal node.next := newNode update <i>firstNode</i> variable if necessary </pre> <p>This function removes a non-null node from a list of size greater than 1 in O(1) time. It copies data from the next node into the node, and then sets the node's <i>next</i> pointer to skip over the next node. </p> <pre><b>function</b> remove(<i>Node</i> node) <b>if</b> node ≠ <b>null</b> and size of list > 1 removedData := node.data node.data := node.next.data node.next = node.next.next <b>return</b> removedData </pre> <div class="mw-heading mw-heading3"><h3 id="Linked_lists_using_arrays_of_nodes">Linked lists using arrays of nodes</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=23" title="Edit section: Linked lists using arrays of nodes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Languages that do not support any type of <a href="/wiki/Reference_(computer_science)" title="Reference (computer science)">reference</a> can still create links by replacing pointers with array indices. The approach is to keep an <a href="/wiki/Array_data_type" class="mw-redirect" title="Array data type">array</a> of <a href="/wiki/Record_(computer_science)" title="Record (computer science)">records</a>, where each record has integer fields indicating the index of the next (and possibly previous) node in the array. Not all nodes in the array need be used. If records are also not supported, <a href="/wiki/Parallel_array" title="Parallel array">parallel arrays</a> can often be used instead. </p><p>As an example, consider the following linked list record that uses arrays instead of pointers: </p> <pre><b>record</b> <i>Entry</i> { <i>integer</i> next; <i>// index of next entry in array</i> <i>integer</i> prev; <i>// previous entry (if double-linked)</i> <i>string</i> name; <i>real</i> balance; } </pre> <p>A linked list can be built by creating an array of these structures, and an integer variable to store the index of the first element. </p> <pre><i>integer</i> listHead <i>Entry</i> Records[1000] </pre> <p>Links between elements are formed by placing the array index of the next (or previous) cell into the Next or Prev field within a given element. For example: </p> <table class="wikitable"> <tbody><tr> <th>Index </th> <th>Next </th> <th>Prev </th> <th>Name </th> <th>Balance </th></tr> <tr> <td>0 </td> <td>1 </td> <td>4 </td> <td>Jones, John </td> <td>123.45 </td></tr> <tr> <td>1 </td> <td>−1 </td> <td>0 </td> <td>Smith, Joseph </td> <td>234.56 </td></tr> <tr> <td>2 (listHead) </td> <td>4 </td> <td>−1 </td> <td>Adams, Adam </td> <td>0.00 </td></tr> <tr> <td>3 </td> <td> </td> <td> </td> <td>Ignore, Ignatius </td> <td>999.99 </td></tr> <tr> <td>4 </td> <td>0 </td> <td>2 </td> <td>Another, Anita </td> <td>876.54 </td></tr> <tr> <td>5 </td> <td> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td>6 </td> <td> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td>7 </td> <td> </td> <td> </td> <td> </td> <td> </td></tr></tbody></table> <p>In the above example, <code>ListHead</code> would be set to 2, the location of the first entry in the list. Notice that entry 3 and 5 through 7 are not part of the list. These cells are available for any additions to the list. By creating a <code>ListFree</code> integer variable, a <a href="/wiki/Free_list" title="Free list">free list</a> could be created to keep track of what cells are available. If all entries are in use, the size of the array would have to be increased or some elements would have to be deleted before new entries could be stored in the list. </p><p>The following code would traverse the list and display names and account balance: </p> <pre>i := listHead <b>while</b> i ≥ 0 <i>// loop through the list</i> print i, Records[i].name, Records[i].balance <i>// print entry</i> i := Records[i].next </pre> <p>When faced with a choice, the advantages of this approach include: </p> <ul><li>The linked list is relocatable, meaning it can be moved about in memory at will, and it can also be quickly and directly <a href="/wiki/Serialization" title="Serialization">serialized</a> for storage on disk or transfer over a network.</li> <li>Especially for a small list, array indexes can occupy significantly less space than a full pointer on many architectures.</li> <li><a href="/wiki/Locality_of_reference" title="Locality of reference">Locality of reference</a> can be improved by keeping the nodes together in memory and by periodically rearranging them, although this can also be done in a general store.</li> <li>Naïve <a href="/wiki/Dynamic_memory_allocation" class="mw-redirect" title="Dynamic memory allocation">dynamic memory allocators</a> can produce an excessive amount of overhead storage for each node allocated; almost no allocation overhead is incurred per node in this approach.</li> <li>Seizing an entry from a pre-allocated array is faster than using dynamic memory allocation for each node, since dynamic memory allocation typically requires a search for a free memory block of the desired size.</li></ul> <p>This approach has one main disadvantage, however: it creates and manages a private memory space for its nodes. This leads to the following issues: </p> <ul><li>It increases complexity of the implementation.</li> <li>Growing a large array when it is full may be difficult or impossible, whereas finding space for a new linked list node in a large, general memory pool may be easier.</li> <li>Adding elements to a dynamic array will occasionally (when it is full) unexpectedly take linear (<a href="/wiki/Big-O_notation" class="mw-redirect" title="Big-O notation">O</a>(n)) instead of constant time (although it is still an <a href="/wiki/Amortized_analysis" title="Amortized analysis">amortized</a> constant).</li> <li>Using a general memory pool leaves more memory for other data if the list is smaller than expected or if many nodes are freed.</li></ul> <p>For these reasons, this approach is mainly used for languages that do not support dynamic memory allocation. These disadvantages are also mitigated if the maximum size of the list is known at the time the array is created. </p> <div class="mw-heading mw-heading2"><h2 id="Language_support">Language support</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=24" title="Edit section: Language support"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Many <a href="/wiki/Programming_language" title="Programming language">programming languages</a> such as <a href="/wiki/Lisp_programming_language" class="mw-redirect" title="Lisp programming language">Lisp</a> and <a href="/wiki/Scheme_(programming_language)" title="Scheme (programming language)">Scheme</a> have singly linked lists built in. In many <a href="/wiki/Functional_programming_language" class="mw-redirect" title="Functional programming language">functional languages</a>, these lists are constructed from nodes, each called a <i><a href="/wiki/Cons" title="Cons">cons</a></i> or <i>cons cell</i>. The cons has two fields: the <i><a href="/wiki/Car_and_cdr" class="mw-redirect" title="Car and cdr">car</a></i>, a reference to the data for that node, and the <i><a href="/wiki/Car_and_cdr" class="mw-redirect" title="Car and cdr">cdr</a></i>, a reference to the next node. Although cons cells can be used to build other data structures, this is their primary purpose. </p><p>In languages that support <a href="/wiki/Abstract_data_type" title="Abstract data type">abstract data types</a> or templates, linked list ADTs or templates are available for building linked lists. In other languages, linked lists are typically built using <a href="/wiki/Reference_(computer_science)" title="Reference (computer science)">references</a> together with <a href="/wiki/Record_(computer_science)" title="Record (computer science)">records</a>. </p> <div class="mw-heading mw-heading2"><h2 id="Internal_and_external_storage">Internal and external storage</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=25" title="Edit section: Internal and external storage"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>When constructing a linked list, one is faced with the choice of whether to store the data of the list directly in the linked list nodes, called <i>internal storage</i>, or merely to store a reference to the data, called <i>external storage</i>. Internal storage has the advantage of making access to the data more efficient, requiring less storage overall, having better <a href="/wiki/Locality_of_reference" title="Locality of reference">locality of reference</a>, and simplifying memory management for the list (its data is allocated and deallocated at the same time as the list nodes). </p><p>External storage, on the other hand, has the advantage of being more generic, in that the same data structure and machine code can be used for a linked list no matter what the size of the data is. It also makes it easy to place the same data in multiple linked lists. Although with internal storage the same data can be placed in multiple lists by including multiple <i>next</i> references in the node data structure, it would then be necessary to create separate routines to add or delete cells based on each field. It is possible to create additional linked lists of elements that use internal storage by using external storage, and having the cells of the additional linked lists store references to the nodes of the linked list containing the data. </p><p>In general, if a set of data structures needs to be included in linked lists, external storage is the best approach. If a set of data structures need to be included in only one linked list, then internal storage is slightly better, unless a generic linked list package using external storage is available. Likewise, if different sets of data that can be stored in the same data structure are to be included in a single linked list, then internal storage would be fine. </p><p>Another approach that can be used with some languages involves having different data structures, but all have the initial fields, including the <i>next</i> (and <i>prev</i> if double linked list) references in the same location. After defining separate structures for each type of data, a generic structure can be defined that contains the minimum amount of data shared by all the other structures and contained at the top (beginning) of the structures. Then generic routines can be created that use the minimal structure to perform linked list type operations, but separate routines can then handle the specific data. This approach is often used in message parsing routines, where several types of messages are received, but all start with the same set of fields, usually including a field for message type. The generic routines are used to add new messages to a queue when they are received, and remove them from the queue in order to process the message. The message type field is then used to call the correct routine to process the specific type of message. </p> <div class="mw-heading mw-heading3"><h3 id="Example_of_internal_and_external_storage">Example of internal and external storage</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=26" title="Edit section: Example of internal and external storage"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>To create a linked list of families and their members, using internal storage, the structure might look like the following: </p> <pre><b>record</b> <i>member</i> { <i>// member of a family</i> <i>member</i> next; <i>string</i> firstName; <i>integer</i> age; } <b>record</b> <i>family</i> { <i>// the family itself</i> <i>family</i> next; <i>string</i> lastName; <i>string</i> address; <i>member</i> members <i>// head of list of members of this family</i> } </pre> <p>To print a complete list of families and their members using internal storage, write: </p> <pre>aFamily := Families <i>// start at head of families list</i> <b>while</b> aFamily ≠ <b>null</b> <i>// loop through list of families</i> print information about family aMember := aFamily.members <i>// get head of list of this family's members</i> <b>while</b> aMember ≠ <b>null</b> <i>// loop through list of members</i> print information about member aMember := aMember.next aFamily := aFamily.next </pre> <p>Using external storage, the following structures can be created: </p> <pre><b>record</b> <i>node</i> { <i>// generic link structure</i> <i>node</i> next; <i>pointer</i> data <i>// generic pointer for data at node</i> } <b>record</b> <i>member</i> { <i>// structure for family member</i> <i>string</i> firstName; <i>integer</i> age } <b>record</b> <i>family</i> { <i>// structure for family</i> <i>string</i> lastName; <i>string</i> address; <i>node</i> members <i>// head of list of members of this family</i> } </pre> <p>To print a complete list of families and their members using external storage, write: </p> <pre>famNode := Families <i>// start at head of families list</i> <b>while</b> famNode ≠ <b>null</b> <i>// loop through list of families</i> aFamily := (family) famNode.data <i>// extract family from node</i> print information about family memNode := aFamily.members <i>// get list of family members</i> <b>while</b> memNode ≠ <b>null</b> <i>// loop through list of members</i> aMember := (member)memNode.data <i>// extract member from node</i> print information about member memNode := memNode.next famNode := famNode.next </pre> <p>Notice that when using external storage, an extra step is needed to extract the record from the node and cast it into the proper data type. This is because both the list of families and the list of members within the family are stored in two linked lists using the same data structure (<i>node</i>), and this language does not have parametric types. </p><p>As long as the number of families that a member can belong to is known at compile time, internal storage works fine. If, however, a member needed to be included in an arbitrary number of families, with the specific number known only at run time, external storage would be necessary. </p> <div class="mw-heading mw-heading3"><h3 id="Speeding_up_search">Speeding up search</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=27" title="Edit section: Speeding up search"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Finding a specific element in a linked list, even if it is sorted, normally requires O(<i>n</i>) time (<a href="/wiki/Linear_search" title="Linear search">linear search</a>). This is one of the primary disadvantages of linked lists over other data structures. In addition to the variants discussed above, below are two simple ways to improve search time. </p><p>In an unordered list, one simple heuristic for decreasing average search time is the <i>move-to-front heuristic</i>, which simply moves an element to the beginning of the list once it is found. This scheme, handy for creating simple caches, ensures that the most recently used items are also the quickest to find again. </p><p>Another common approach is to "<a href="/wiki/Index_(database)" class="mw-redirect" title="Index (database)">index</a>" a linked list using a more efficient external data structure. For example, one can build a <a href="/wiki/Red%E2%80%93black_tree" title="Red–black tree">red–black tree</a> or <a href="/wiki/Hash_table" title="Hash table">hash table</a> whose elements are references to the linked list nodes. Multiple such indexes can be built on a single list. The disadvantage is that these indexes may need to be updated each time a node is added or removed (or at least, before that index is used again). </p> <div class="mw-heading mw-heading3"><h3 id="Random-access_lists">Random-access lists</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=28" title="Edit section: Random-access lists"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A <a href="/w/index.php?title=Random_access_list&action=edit&redlink=1" class="new" title="Random access list (page does not exist)">random-access list</a> is a list with support for fast random access to read or modify any element in the list.<sup id="cite_ref-okasaki_8-0" class="reference"><a href="#cite_note-okasaki-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> One possible implementation is a <a href="/w/index.php?title=Skew_binary_random_access_list&action=edit&redlink=1" class="new" title="Skew binary random access list (page does not exist)">skew binary random-access list</a> using the <a href="/wiki/Skew_binary_number_system" title="Skew binary number system">skew binary number system</a>, which involves a list of trees with special properties; this allows worst-case constant time head/cons operations, and worst-case logarithmic time random access to an element by index.<sup id="cite_ref-okasaki_8-1" class="reference"><a href="#cite_note-okasaki-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Random-access lists can be implemented as <a href="/wiki/Persistent_data_structure" title="Persistent data structure">persistent data structures</a>.<sup id="cite_ref-okasaki_8-2" class="reference"><a href="#cite_note-okasaki-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> </p><p>Random-access lists can be viewed as immutable linked lists in that they likewise support the same O(1) head and tail operations.<sup id="cite_ref-okasaki_8-3" class="reference"><a href="#cite_note-okasaki-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> </p><p>A simple extension to random-access lists is the <a href="/w/index.php?title=Min-list&action=edit&redlink=1" class="new" title="Min-list (page does not exist)">min-list</a>, which provides an additional operation that yields the minimum element in the entire list in constant time (without<sup class="noprint Inline-Template" style="margin-left:0.1em; white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Please_clarify" title="Wikipedia:Please clarify"><span title="The text near this tag may need clarification or removal of jargon. (October 2011)">clarification needed</span></a></i>]</sup> mutation complexities).<sup id="cite_ref-okasaki_8-4" class="reference"><a href="#cite_note-okasaki-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Related_data_structures">Related data structures</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=29" title="Edit section: Related data structures"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Both <a href="/wiki/Stack_(data_structure)" class="mw-redirect" title="Stack (data structure)">stacks</a> and <a href="/wiki/Queue_(data_structure)" class="mw-redirect" title="Queue (data structure)">queues</a> are often implemented using linked lists, and simply restrict the type of operations which are supported. </p><p>The <a href="/wiki/Skip_list" title="Skip list">skip list</a> is a linked list augmented with layers of pointers for quickly jumping over large numbers of elements, and then descending to the next layer. This process continues down to the bottom layer, which is the actual list. </p><p>A <a href="/wiki/Binary_tree" title="Binary tree">binary tree</a> can be seen as a type of linked list where the elements are themselves linked lists of the same nature. The result is that each node may include a reference to the first node of one or two other linked lists, which, together with their contents, form the subtrees below that node. </p><p>An <a href="/wiki/Unrolled_linked_list" title="Unrolled linked list">unrolled linked list</a> is a linked list in which each node contains an array of data values. This leads to improved <a href="/wiki/CPU_cache" title="CPU cache">cache</a> performance, since more list elements are contiguous in memory, and reduced memory overhead, because less metadata needs to be stored for each element of the list. </p><p>A <a href="/wiki/Hash_table" title="Hash table">hash table</a> may use linked lists to store the chains of items that hash to the same position in the hash table. </p><p>A <a href="/wiki/Heap_(data_structure)" title="Heap (data structure)">heap</a> shares some of the ordering properties of a linked list, but is almost always implemented using an array. Instead of references from node to node, the next and previous data indexes are calculated using the current data's index. </p><p>A <a href="/wiki/Self-organizing_list" title="Self-organizing list">self-organizing list</a> rearranges its nodes based on some heuristic which reduces search times for data retrieval by keeping commonly accessed nodes at the head of the list. </p> <div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=30" title="Edit section: Notes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text">The amount of control data required for a dynamic array is usually of the form <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle K+B*n}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>K</mi> <mo>+</mo> <mi>B</mi> <mo>∗<!-- ∗ --></mo> <mi>n</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle K+B*n}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5eccb77f2fbdeffd7b327d68cd4d0e6ea95342d3" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:10.26ex; height:2.343ex;" alt="{\displaystyle K+B*n}" /></span>, where <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle K}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>K</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle K}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/2b76fce82a62ed5461908f0dc8f037de4e3686b0" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.066ex; height:2.176ex;" alt="{\displaystyle K}" /></span> is a per-array constant, <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle B}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>B</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle B}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/47136aad860d145f75f3eed3022df827cee94d7a" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.764ex; height:2.176ex;" alt="{\displaystyle B}" /></span> is a per-dimension constant, and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>n</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle n}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a601995d55609f2d9f5e233e36fbe9ea26011b3b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.395ex; height:1.676ex;" alt="{\displaystyle n}" /></span> is the number of dimensions. <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle K}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>K</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle K}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/2b76fce82a62ed5461908f0dc8f037de4e3686b0" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.066ex; height:2.176ex;" alt="{\displaystyle K}" /></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle B}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>B</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle B}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/47136aad860d145f75f3eed3022df827cee94d7a" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.764ex; height:2.176ex;" alt="{\displaystyle B}" /></span> are typically on the order of 10 bytes.</span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="References">References</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=31" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1239543626" /><div class="reflist"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-knuth-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-knuth_1-0">^</a></b></span> <span class="reference-text"> <style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite id="CITEREFKnuth1998" class="citation book cs1 cs1-prop-long-vol"><a href="/wiki/Donald_Knuth" title="Donald Knuth">Knuth, Donald</a> (1998). <i>The Art of Computer Programming</i>. Vol. 3: <i>Sorting and Searching</i> (2nd ed.). Addison-Wesley. p. 547. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-0-201-89685-5" title="Special:BookSources/978-0-201-89685-5"><bdi>978-0-201-89685-5</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=The+Art+of+Computer+Programming&rft.pages=547&rft.edition=2nd&rft.pub=Addison-Wesley&rft.date=1998&rft.isbn=978-0-201-89685-5&rft.aulast=Knuth&rft.aufirst=Donald&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></span> </li> <li id="cite_note-:0-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-:0_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-:0_2-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20150923015150/http://www.osronline.com/article.cfm?article=499">"The NT Insider:Kernel-Mode Basics: Windows Linked Lists"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.osronline.com/article.cfm?article%3D499">the original</a> on 2015-09-23<span class="reference-accessdate">. Retrieved <span class="nowrap">2015-07-31</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=The+NT+Insider%3AKernel-Mode+Basics%3A+Windows+Linked+Lists&rft_id=http%3A%2F%2Fwww.osronline.com%2Farticle.cfm%3Farticle%253D499&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></span> </li> <li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFButlerHoglund" class="citation web cs1">Butler, Jamie; Hoglund, Greg. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20161001201702/https://www.cs.dartmouth.edu/~sergey/me/cs/cs108/rootkits/bh-us-04-butler.pdf">"VICE – Catch the hookers! (Plus new rootkit techniques)"</a> <span class="cs1-format">(PDF)</span>. Archived from <a rel="nofollow" class="external text" href="https://www.cs.dartmouth.edu/~sergey/me/cs/cs108/rootkits/bh-us-04-butler.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2016-10-01<span class="reference-accessdate">. Retrieved <span class="nowrap">2021-08-31</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=VICE+%E2%80%93+Catch+the+hookers%21+%28Plus+new+rootkit+techniques%29&rft.aulast=Butler&rft.aufirst=Jamie&rft.au=Hoglund%2C+Greg&rft_id=https%3A%2F%2Fwww.cs.dartmouth.edu%2F~sergey%2Fme%2Fcs%2Fcs108%2Frootkits%2Fbh-us-04-butler.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></span> </li> <li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFBrodnikCarlssonSedgewickMunro1999" class="citation cs2">Brodnik, Andrej; Carlsson, Svante; <a href="/wiki/Robert_Sedgewick_(computer_scientist)" title="Robert Sedgewick (computer scientist)">Sedgewick, Robert</a>; Munro, JI; Demaine, ED (1999), <a rel="nofollow" class="external text" href="http://www.cs.uwaterloo.ca/research/tr/1999/09/CS-99-09.pdf"><i>Resizable Arrays in Optimal Time and Space (Technical Report CS-99-09)</i></a> <span class="cs1-format">(PDF)</span>, Department of Computer Science, University of Waterloo</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Resizable+Arrays+in+Optimal+Time+and+Space+%28Technical+Report+CS-99-09%29&rft.pub=Department+of+Computer+Science%2C+University+of+Waterloo&rft.date=1999&rft.aulast=Brodnik&rft.aufirst=Andrej&rft.au=Carlsson%2C+Svante&rft.au=Sedgewick%2C+Robert&rft.au=Munro%2C+JI&rft.au=Demaine%2C+ED&rft_id=http%3A%2F%2Fwww.cs.uwaterloo.ca%2Fresearch%2Ftr%2F1999%2F09%2FCS-99-09.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></span> </li> <li id="cite_note-okasakiComparison-5"><span class="mw-cite-backlink">^ <a href="#cite_ref-okasakiComparison_5-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-okasakiComparison_5-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-okasakiComparison_5-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFChris_Okasaki1995" class="citation journal cs1">Chris Okasaki (1995). "Purely Functional Random-Access Lists". <i>Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture</i>: <span class="nowrap">86–</span>95. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F224164.224187">10.1145/224164.224187</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Proceedings+of+the+Seventh+International+Conference+on+Functional+Programming+Languages+and+Computer+Architecture&rft.atitle=Purely+Functional+Random-Access+Lists&rft.pages=%3Cspan+class%3D%22nowrap%22%3E86-%3C%2Fspan%3E95&rft.date=1995&rft_id=info%3Adoi%2F10.1145%2F224164.224187&rft.au=Chris+Okasaki&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></span> </li> <li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFFordTopp2002" class="citation book cs1">Ford, William; Topp, William (2002). <i>Data Structures with C++ using STL</i> (Second ed.). Prentice-Hall. pp. <span class="nowrap">466–</span>467. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-13-085850-1" title="Special:BookSources/0-13-085850-1"><bdi>0-13-085850-1</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Data+Structures+with+C%2B%2B+using+STL&rft.pages=%3Cspan+class%3D%22nowrap%22%3E466-%3C%2Fspan%3E467&rft.edition=Second&rft.pub=Prentice-Hall&rft.date=2002&rft.isbn=0-13-085850-1&rft.aulast=Ford&rft.aufirst=William&rft.au=Topp%2C+William&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></span> </li> <li id="cite_note-okasaki-8"><span class="mw-cite-backlink">^ <a href="#cite_ref-okasaki_8-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-okasaki_8-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-okasaki_8-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-okasaki_8-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-okasaki_8-4"><sup><i><b>e</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFOkasaki1995" class="citation book cs1">Okasaki, Chris (1995). <a rel="nofollow" class="external text" href="http://cs.oberlin.edu/~jwalker/refs/fpca95.ps"><i>Purely Functional Random-Access Lists</i></a> <span class="cs1-format">(PS)</span>. ACM Press. pp. <span class="nowrap">86–</span>95<span class="reference-accessdate">. Retrieved <span class="nowrap">May 7,</span> 2015</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Purely+Functional+Random-Access+Lists&rft.pages=%3Cspan+class%3D%22nowrap%22%3E86-%3C%2Fspan%3E95&rft.pub=ACM+Press&rft.date=1995&rft.aulast=Okasaki&rft.aufirst=Chris&rft_id=http%3A%2F%2Fcs.oberlin.edu%2F~jwalker%2Frefs%2Ffpca95.ps&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span> <span class="cs1-visible-error citation-comment"><code class="cs1-code">{{<a href="/wiki/Template:Cite_book" title="Template:Cite book">cite book</a>}}</code>: </span><span class="cs1-visible-error citation-comment"><code class="cs1-code">|work=</code> ignored (<a href="/wiki/Help:CS1_errors#periodical_ignored" title="Help:CS1 errors">help</a>)</span></span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=32" title="Edit section: Further reading"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1">Juan, Angel (2006). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120106141608/http://www.uoc.edu/in3/emath/docs/java/ch20.pdf">"Ch20 –Data Structures; ID06 - PROGRAMMING with JAVA (slide part of the book 'Big Java', by CayS. Horstmann)"</a> <span class="cs1-format">(PDF)</span>. p. 3. Archived from <a rel="nofollow" class="external text" href="http://www.uoc.edu/in3/emath/docs/java/ch20.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2012-01-06<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-07-10</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Ch20+%E2%80%93Data+Structures%3B+ID06+-+PROGRAMMING+with+JAVA+%28slide+part+of+the+book+%27Big+Java%27%2C+by+CayS.+Horstmann%29&rft.pages=3&rft.date=2006&rft.aulast=Juan&rft.aufirst=Angel&rft_id=http%3A%2F%2Fwww.uoc.edu%2Fin3%2Femath%2Fdocs%2Fjava%2Fch20.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1">Black, Paul E. (2004-08-16). Pieterse, Vreda; Black, Paul E. (eds.). <a rel="nofollow" class="external text" href="http://nist.gov/dads/HTML/linkedList.html">"linked list"</a>. <i>Dictionary of Algorithms and Data Structures</i>. <a href="/wiki/National_Institute_of_Standards_and_Technology" title="National Institute of Standards and Technology">National Institute of Standards and Technology</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2004-12-14</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Dictionary+of+Algorithms+and+Data+Structures&rft.atitle=linked+list&rft.date=2004-08-16&rft.aulast=Black&rft.aufirst=Paul+E.&rft_id=http%3A%2F%2Fnist.gov%2Fdads%2FHTML%2FlinkedList.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation book cs1">Antonakos, James L.; Mansfield, Kenneth C. Jr. (1999). <a rel="nofollow" class="external text" href="https://archive.org/details/practicaldatastr0000anto/page/165"><i>Practical Data Structures Using C/C++</i></a>. Prentice-Hall. pp. <a rel="nofollow" class="external text" href="https://archive.org/details/practicaldatastr0000anto/page/165">165–190</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-13-280843-9" title="Special:BookSources/0-13-280843-9"><bdi>0-13-280843-9</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Practical+Data+Structures+Using+C%2FC%2B%2B&rft.pages=165-190&rft.pub=Prentice-Hall&rft.date=1999&rft.isbn=0-13-280843-9&rft.aulast=Antonakos&rft.aufirst=James+L.&rft.au=Mansfield%2C+Kenneth+C.+Jr.&rft_id=https%3A%2F%2Farchive.org%2Fdetails%2Fpracticaldatastr0000anto%2Fpage%2F165&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation book cs1">Collins, William J. (2005) [2002]. <i>Data Structures and the Java Collections Framework</i>. New York: McGraw Hill. pp. <span class="nowrap">239–</span>303. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-07-282379-8" title="Special:BookSources/0-07-282379-8"><bdi>0-07-282379-8</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Data+Structures+and+the+Java+Collections+Framework&rft.place=New+York&rft.pages=%3Cspan+class%3D%22nowrap%22%3E239-%3C%2Fspan%3E303&rft.pub=McGraw+Hill&rft.date=2005&rft.isbn=0-07-282379-8&rft.aulast=Collins&rft.aufirst=William+J.&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation book cs1"><a href="/wiki/Thomas_H._Cormen" title="Thomas H. Cormen">Cormen, Thomas H.</a>; <a href="/wiki/Charles_E._Leiserson" title="Charles E. Leiserson">Leiserson, Charles E.</a>; <a href="/wiki/Ronald_L._Rivest" class="mw-redirect" title="Ronald L. Rivest">Rivest, Ronald L.</a>; <a href="/wiki/Clifford_Stein" title="Clifford Stein">Stein, Clifford</a> (2003). <i><a href="/wiki/Introduction_to_Algorithms" title="Introduction to Algorithms">Introduction to Algorithms</a></i>. MIT Press. pp. <span class="nowrap">205–</span>213, <span class="nowrap">501–</span>505. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-262-03293-7" title="Special:BookSources/0-262-03293-7"><bdi>0-262-03293-7</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Introduction+to+Algorithms&rft.pages=%3Cspan+class%3D%22nowrap%22%3E205-%3C%2Fspan%3E213%2C+%3Cspan+class%3D%22nowrap%22%3E501-%3C%2Fspan%3E505&rft.pub=MIT+Press&rft.date=2003&rft.isbn=0-262-03293-7&rft.aulast=Cormen&rft.aufirst=Thomas+H.&rft.au=Leiserson%2C+Charles+E.&rft.au=Rivest%2C+Ronald+L.&rft.au=Stein%2C+Clifford&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation book cs1"><a href="/wiki/Thomas_H._Cormen" title="Thomas H. Cormen">Cormen, Thomas H.</a>; <a href="/wiki/Charles_E._Leiserson" title="Charles E. Leiserson">Leiserson, Charles E.</a>; <a href="/wiki/Ronald_L._Rivest" class="mw-redirect" title="Ronald L. Rivest">Rivest, Ronald L.</a>; <a href="/wiki/Clifford_Stein" title="Clifford Stein">Stein, Clifford</a> (2001). "10.2: Linked lists". <i><a href="/wiki/Introduction_to_Algorithms" title="Introduction to Algorithms">Introduction to Algorithms</a></i> (2nd ed.). MIT Press. pp. <span class="nowrap">204–</span>209. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-262-03293-7" title="Special:BookSources/0-262-03293-7"><bdi>0-262-03293-7</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=10.2%3A+Linked+lists&rft.btitle=Introduction+to+Algorithms&rft.pages=%3Cspan+class%3D%22nowrap%22%3E204-%3C%2Fspan%3E209&rft.edition=2nd&rft.pub=MIT+Press&rft.date=2001&rft.isbn=0-262-03293-7&rft.aulast=Cormen&rft.aufirst=Thomas+H.&rft.au=Leiserson%2C+Charles+E.&rft.au=Rivest%2C+Ronald+L.&rft.au=Stein%2C+Clifford&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation journal cs1">Green, Bert F. Jr. (1961). "Computer Languages for Symbol Manipulation". <i>IRE Transactions on Human Factors in Electronics</i> (2): <span class="nowrap">3–</span>8. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FTHFE2.1961.4503292">10.1109/THFE2.1961.4503292</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=IRE+Transactions+on+Human+Factors+in+Electronics&rft.atitle=Computer+Languages+for+Symbol+Manipulation&rft.issue=2&rft.pages=%3Cspan+class%3D%22nowrap%22%3E3-%3C%2Fspan%3E8&rft.date=1961&rft_id=info%3Adoi%2F10.1109%2FTHFE2.1961.4503292&rft.aulast=Green&rft.aufirst=Bert+F.+Jr.&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation journal cs1"><a href="/wiki/John_McCarthy_(computer_scientist)" title="John McCarthy (computer scientist)">McCarthy, John</a> (1960). <a rel="nofollow" class="external text" href="http://www-formal.stanford.edu/jmc/recursive.html">"Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I"</a>. <i><a href="/wiki/Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a></i>. <b>3</b> (4): 184. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F367177.367199">10.1145/367177.367199</a></span>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:1489409">1489409</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Communications+of+the+ACM&rft.atitle=Recursive+Functions+of+Symbolic+Expressions+and+Their+Computation+by+Machine%2C+Part+I&rft.volume=3&rft.issue=4&rft.pages=184&rft.date=1960&rft_id=info%3Adoi%2F10.1145%2F367177.367199&rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A1489409%23id-name%3DS2CID&rft.aulast=McCarthy&rft.aufirst=John&rft_id=http%3A%2F%2Fwww-formal.stanford.edu%2Fjmc%2Frecursive.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation book cs1"><a href="/wiki/Donald_Knuth" title="Donald Knuth">Knuth, Donald</a> (1997). "2.2.3-2.2.5". <i>Fundamental Algorithms</i> (3rd ed.). Addison-Wesley. pp. <span class="nowrap">254–</span>298. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-201-89683-4" title="Special:BookSources/0-201-89683-4"><bdi>0-201-89683-4</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=2.2.3-2.2.5&rft.btitle=Fundamental+Algorithms&rft.pages=%3Cspan+class%3D%22nowrap%22%3E254-%3C%2Fspan%3E298&rft.edition=3rd&rft.pub=Addison-Wesley&rft.date=1997&rft.isbn=0-201-89683-4&rft.aulast=Knuth&rft.aufirst=Donald&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation journal cs1"><a href="/wiki/Allen_Newell" title="Allen Newell">Newell, Allen</a>; Shaw, F. C. (1957). "Programming the Logic Theory Machine". <i>Proceedings of the Western Joint Computer Conference</i>: <span class="nowrap">230–</span>240.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Proceedings+of+the+Western+Joint+Computer+Conference&rft.atitle=Programming+the+Logic+Theory+Machine&rft.pages=%3Cspan+class%3D%22nowrap%22%3E230-%3C%2Fspan%3E240&rft.date=1957&rft.aulast=Newell&rft.aufirst=Allen&rft.au=Shaw%2C+F.+C.&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1">Parlante, Nick (2001). <a rel="nofollow" class="external text" href="http://cslibrary.stanford.edu/103/LinkedListBasics.pdf">"Linked list basics"</a> <span class="cs1-format">(PDF)</span>. Stanford University<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-09-21</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Linked+list+basics&rft.pub=Stanford+University&rft.date=2001&rft.aulast=Parlante&rft.aufirst=Nick&rft_id=http%3A%2F%2Fcslibrary.stanford.edu%2F103%2FLinkedListBasics.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation book cs1"><a href="/wiki/Robert_Sedgewick_(computer_scientist)" title="Robert Sedgewick (computer scientist)">Sedgewick, Robert</a> (1998). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/algorithmsinc00sedg/page/90"><i>Algorithms in C</i></a></span>. Addison Wesley. pp. <a rel="nofollow" class="external text" href="https://archive.org/details/algorithmsinc00sedg/page/90">90–109</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-201-31452-5" title="Special:BookSources/0-201-31452-5"><bdi>0-201-31452-5</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Algorithms+in+C&rft.pages=90-109&rft.pub=Addison+Wesley&rft.date=1998&rft.isbn=0-201-31452-5&rft.aulast=Sedgewick&rft.aufirst=Robert&rft_id=https%3A%2F%2Farchive.org%2Fdetails%2Falgorithmsinc00sedg%2Fpage%2F90&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation book cs1">Shaffer, Clifford A. (1998). <i>A Practical Introduction to Data Structures and Algorithm Analysis</i>. New Jersey: Prentice Hall. pp. <span class="nowrap">77–</span>102. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-13-660911-2" title="Special:BookSources/0-13-660911-2"><bdi>0-13-660911-2</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=A+Practical+Introduction+to+Data+Structures+and+Algorithm+Analysis&rft.place=New+Jersey&rft.pages=%3Cspan+class%3D%22nowrap%22%3E77-%3C%2Fspan%3E102&rft.pub=Prentice+Hall&rft.date=1998&rft.isbn=0-13-660911-2&rft.aulast=Shaffer&rft.aufirst=Clifford+A.&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation journal cs1"><a href="/wiki/Maurice_Vincent_Wilkes" class="mw-redirect" title="Maurice Vincent Wilkes">Wilkes, Maurice Vincent</a> (1964). "An Experiment with a Self-compiling Compiler for a Simple List-Processing Language". <i>Annual Review in Automatic Programming</i>. <b>4</b> (1). Pergamon Press: 1. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0066-4138%2864%2990013-8">10.1016/0066-4138(64)90013-8</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Annual+Review+in+Automatic+Programming&rft.atitle=An+Experiment+with+a+Self-compiling+Compiler+for+a+Simple+List-Processing+Language&rft.volume=4&rft.issue=1&rft.pages=1&rft.date=1964&rft_id=info%3Adoi%2F10.1016%2F0066-4138%2864%2990013-8&rft.aulast=Wilkes&rft.aufirst=Maurice+Vincent&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation journal cs1"><a href="/wiki/Maurice_Vincent_Wilkes" class="mw-redirect" title="Maurice Vincent Wilkes">Wilkes, Maurice Vincent</a> (1964). "Lists and Why They are Useful". <i>Proceeds of the ACM National Conference, Philadelphia 1964</i> (P–64). ACM: F1–1.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Proceeds+of+the+ACM+National+Conference%2C+Philadelphia+1964&rft.atitle=Lists+and+Why+They+are+Useful&rft.issue=P%E2%80%9364&rft.pages=F1-1&rft.date=1964&rft.aulast=Wilkes&rft.aufirst=Maurice+Vincent&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1">Shanmugasundaram, Kulesh (2005-04-04). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20090925130610/http://isis.poly.edu/kulesh/stuff/src/klist/">"Linux Kernel Linked List Explained"</a>. Archived from <a rel="nofollow" class="external text" href="http://isis.poly.edu/kulesh/stuff/src/klist/">the original</a> on 2009-09-25<span class="reference-accessdate">. Retrieved <span class="nowrap">2009-09-21</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Linux+Kernel+Linked+List+Explained&rft.date=2005-04-04&rft.aulast=Shanmugasundaram&rft.aufirst=Kulesh&rft_id=http%3A%2F%2Fisis.poly.edu%2Fkulesh%2Fstuff%2Fsrc%2Fklist%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALinked+list" class="Z3988"></span></li></ul> <div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Linked_list&action=edit&section=33" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1235681985">.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}</style><style data-mw-deduplicate="TemplateStyles:r1237033735">@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}</style><div class="side-box side-box-right plainlinks sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}</style> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><a href="/wiki/File:Commons-logo.svg" class="mw-file-description"><img alt="" src="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/40px-Commons-logo.svg.png" decoding="async" width="30" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/60px-Commons-logo.svg.png 1.5x" data-file-width="1024" data-file-height="1376" /></a></span></div> <div class="side-box-text plainlist">Wikimedia Commons has media related to <span style="font-weight: bold; font-style: italic;"><a href="https://commons.wikimedia.org/wiki/Category:Linked_lists" class="extiw" title="commons:Category:Linked lists">Linked lists</a></span>.</div></div> </div> <ul><li><a rel="nofollow" class="external text" href="http://nist.gov/dads/HTML/linkedList.html">Description</a> from the <a href="/wiki/Dictionary_of_Algorithms_and_Data_Structures" class="mw-redirect" title="Dictionary of Algorithms and Data Structures">Dictionary of Algorithms and Data Structures</a></li> <li><a rel="nofollow" class="external text" href="http://cslibrary.stanford.edu/103/">Introduction to Linked Lists</a>, Stanford University Computer Science Library</li> <li><a rel="nofollow" class="external text" href="http://cslibrary.stanford.edu/105/">Linked List Problems</a>, Stanford University Computer Science Library</li> <li><a rel="nofollow" class="external text" href="http://opendatastructures.org/versions/edition-0.1g/ods-python/3_Linked_Lists.html">Open Data Structures - Chapter 3 - Linked Lists</a>, <a href="/wiki/Pat_Morin" title="Pat Morin">Pat Morin</a></li> <li><a rel="nofollow" class="external text" href="https://patents.google.com/patent/US7028023">Patent for the idea of having nodes which are in several linked lists simultaneously</a> (note that this technique was widely used for many decades before the patent was granted)</li> <li><a rel="nofollow" class="external text" href="https://pvs-studio.com/en/blog/terms/6680/">Implementation of a singly linked list in C</a></li> <li><a rel="nofollow" class="external text" href="https://pvs-studio.com/en/blog/terms/6684/">Implementation of a singly linked list in C++</a></li> <li><a rel="nofollow" class="external text" href="https://pvs-studio.com/en/blog/terms/6682/">Implementation of a doubly linked list in C</a></li> <li><a rel="nofollow" class="external text" href="https://pvs-studio.com/en/blog/terms/6683/">Implementation of a doubly linked list in C++</a></li></ul> <div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}</style><style data-mw-deduplicate="TemplateStyles:r1236075235">.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}</style></div><div role="navigation" class="navbox" aria-labelledby="Data_structures216" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><style data-mw-deduplicate="TemplateStyles:r1239400231">.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}</style><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:Data_structures" title="Template:Data structures"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:Data_structures" title="Template talk:Data structures"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:Data_structures" title="Special:EditPage/Template:Data structures"><abbr title="Edit this template">e</abbr></a></li></ul></div><div id="Data_structures216" style="font-size:114%;margin:0 4em"><a href="/wiki/Data_structure" title="Data structure">Data structures</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">Types</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Collection_(abstract_data_type)" title="Collection (abstract data type)">Collection</a></li> <li><a href="/wiki/Container_(abstract_data_type)" title="Container (abstract data type)">Container</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Abstract_data_type" title="Abstract data type">Abstract</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Associative_array" title="Associative array">Associative array</a> <ul><li><a href="/wiki/Multimap" title="Multimap">Multimap</a></li> <li><a href="/wiki/Retrieval_Data_Structure" title="Retrieval Data Structure">Retrieval Data Structure</a></li></ul></li> <li><a href="/wiki/List_(abstract_data_type)" title="List (abstract data type)">List</a></li> <li><a href="/wiki/Stack_(abstract_data_type)" title="Stack (abstract data type)">Stack</a></li> <li><a href="/wiki/Queue_(abstract_data_type)" title="Queue (abstract data type)">Queue</a> <ul><li><a href="/wiki/Double-ended_queue" title="Double-ended queue">Double-ended queue</a></li></ul></li> <li><a href="/wiki/Priority_queue" title="Priority queue">Priority queue</a> <ul><li><a href="/wiki/Double-ended_priority_queue" title="Double-ended priority queue">Double-ended priority queue</a></li></ul></li> <li><a href="/wiki/Set_(abstract_data_type)" title="Set (abstract data type)">Set</a> <ul><li><a href="/wiki/Set_(abstract_data_type)#Multiset" title="Set (abstract data type)">Multiset</a></li> <li><a href="/wiki/Disjoint-set_data_structure" title="Disjoint-set data structure">Disjoint-set</a></li></ul></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Array_(data_structure)" title="Array (data structure)">Arrays</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Bit_array" title="Bit array">Bit array</a></li> <li><a href="/wiki/Circular_buffer" title="Circular buffer">Circular buffer</a></li> <li><a href="/wiki/Dynamic_array" title="Dynamic array">Dynamic array</a></li> <li><a href="/wiki/Hash_table" title="Hash table">Hash table</a></li> <li><a href="/wiki/Hashed_array_tree" title="Hashed array tree">Hashed array tree</a></li> <li><a href="/wiki/Sparse_matrix" title="Sparse matrix">Sparse matrix</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Linked_data_structure" title="Linked data structure">Linked</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Association_list" title="Association list">Association list</a></li> <li><a class="mw-selflink selflink">Linked list</a></li> <li><a href="/wiki/Skip_list" title="Skip list">Skip list</a></li> <li><a href="/wiki/Unrolled_linked_list" title="Unrolled linked list">Unrolled linked list</a></li> <li><a href="/wiki/XOR_linked_list" title="XOR linked list">XOR linked list</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">Trees</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/B-tree" title="B-tree">B-tree</a></li> <li><a href="/wiki/Binary_search_tree" title="Binary search tree">Binary search tree</a> <ul><li><a href="/wiki/AA_tree" title="AA tree">AA tree</a></li> <li><a href="/wiki/AVL_tree" title="AVL tree">AVL tree</a></li> <li><a href="/wiki/Red%E2%80%93black_tree" title="Red–black tree">Red–black tree</a></li> <li><a href="/wiki/Self-balancing_binary_search_tree" title="Self-balancing binary search tree">Self-balancing tree</a></li> <li><a href="/wiki/Splay_tree" title="Splay tree">Splay tree</a></li></ul></li> <li><a href="/wiki/Heap_(data_structure)" title="Heap (data structure)">Heap</a> <ul><li><a href="/wiki/Binary_heap" title="Binary heap">Binary heap</a></li> <li><a href="/wiki/Binomial_heap" title="Binomial heap">Binomial heap</a></li> <li><a href="/wiki/Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a></li></ul></li> <li><a href="/wiki/R-tree" title="R-tree">R-tree</a> <ul><li><a href="/wiki/R*_tree" class="mw-redirect" title="R* tree">R* tree</a></li> <li><a href="/wiki/R%2B_tree" title="R+ tree">R+ tree</a></li> <li><a href="/wiki/Hilbert_R-tree" title="Hilbert R-tree">Hilbert R-tree</a></li></ul></li> <li><a href="/wiki/Trie" title="Trie">Trie</a> <ul><li><a href="/wiki/Hash_tree_(persistent_data_structure)" title="Hash tree (persistent data structure)">Hash tree</a></li></ul></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Graph_(abstract_data_type)" title="Graph (abstract data type)">Graphs</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Binary_decision_diagram" title="Binary decision diagram">Binary decision diagram</a></li> <li><a href="/wiki/Directed_acyclic_graph" title="Directed acyclic graph">Directed acyclic graph</a></li> <li><a href="/wiki/Deterministic_acyclic_finite_state_automaton" title="Deterministic acyclic finite state automaton">Directed acyclic word graph</a></li></ul> </div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div> <ul><li><a href="/wiki/List_of_data_structures" title="List of data structures">List of data structures</a></li></ul> </div></td></tr></tbody></table></div> <div class="navbox-styles"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236075235" /></div><div role="navigation" class="navbox authority-control" aria-label="Navbox391" style="padding:3px"><table class="nowraplinks hlist navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Help:Authority_control" title="Help:Authority control">Authority control databases</a>: National <span class="mw-valign-text-top noprint" typeof="mw:File/Frameless"><a href="https://www.wikidata.org/wiki/Q7003418#identifiers" title="Edit this at Wikidata"><img alt="Edit this at Wikidata" src="//upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png" decoding="async" width="10" height="10" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/15px-OOjs_UI_icon_edit-ltr-progressive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/20px-OOjs_UI_icon_edit-ltr-progressive.svg.png 2x" data-file-width="20" data-file-height="20" /></a></span></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://d-nb.info/gnd/4783888-7">Germany</a></span></li></ul></div></td></tr></tbody></table></div> <!-- NewPP limit report Parsed by mw‐web.eqiad.main‐8669bc5c8‐2m9bx Cached time: 20250318155436 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.634 seconds Real time usage: 0.841 seconds Preprocessor visited node count: 2486/1000000 Post‐expand include size: 74860/2097152 bytes Template argument size: 2485/2097152 bytes Highest expansion depth: 13/100 Expensive parser function count: 8/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 87472/5000000 bytes Lua time usage: 0.391/10.000 seconds Lua memory usage: 6591718/52428800 bytes Number of Wikibase entities loaded: 1/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 673.805 1 -total 29.65% 199.776 2 Template:Reflist 25.95% 174.869 10 Template:Cite_book 15.23% 102.592 1 Template:Data_structures 14.84% 100.024 1 Template:Navbox 10.00% 67.367 1 Template:Commons_category 9.80% 66.065 1 Template:Short_description 9.66% 65.101 1 Template:Sister_project 9.40% 63.358 1 Template:Side_box 8.83% 59.474 1 Template:More_footnotes_needed --> <!-- Saved in parser cache with key enwiki:pcache:18167:|#|:idhash:canonical and timestamp 20250318155436 and revision id 1270124078. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?useformat=desktop&type=1x1&usesul3=0" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Linked_list&oldid=1270124078">https://en.wikipedia.org/w/index.php?title=Linked_list&oldid=1270124078</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Category</a>: <ul><li><a href="/wiki/Category:Linked_lists" title="Category:Linked lists">Linked lists</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:CS1:_long_volume_value" title="Category:CS1: long volume value">CS1: long volume value</a></li><li><a href="/wiki/Category:CS1_errors:_periodical_ignored" title="Category:CS1 errors: periodical ignored">CS1 errors: periodical ignored</a></li><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_is_different_from_Wikidata" title="Category:Short description is different from Wikidata">Short description is different from Wikidata</a></li><li><a href="/wiki/Category:Articles_lacking_in-text_citations_from_March_2012" title="Category:Articles lacking in-text citations from March 2012">Articles lacking in-text citations from March 2012</a></li><li><a href="/wiki/Category:All_articles_lacking_in-text_citations" title="Category:All articles lacking in-text citations">All articles lacking in-text citations</a></li><li><a href="/wiki/Category:All_articles_with_unsourced_statements" title="Category:All articles with unsourced statements">All articles with unsourced statements</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_January_2019" title="Category:Articles with unsourced statements from January 2019">Articles with unsourced statements from January 2019</a></li><li><a href="/wiki/Category:Pages_with_plain_IPA" title="Category:Pages with plain IPA">Pages with plain IPA</a></li><li><a href="/wiki/Category:Wikipedia_articles_needing_clarification_from_October_2011" title="Category:Wikipedia articles needing clarification from October 2011">Wikipedia articles needing clarification from October 2011</a></li><li><a href="/wiki/Category:Commons_category_link_is_on_Wikidata" title="Category:Commons category link is on Wikidata">Commons category link is on Wikidata</a></li><li><a href="/wiki/Category:Articles_with_example_C_code" title="Category:Articles with example C code">Articles with example C code</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 18 January 2025, at 01:21<span class="anonymous-show"> (UTC)</span>.</li> <li id="footer-info-copyright">Text is available under the <a href="/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" title="Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License">Creative Commons Attribution-ShareAlike 4.0 License</a>; additional terms may apply. By using this site, you agree to the <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use" class="extiw" title="foundation:Special:MyLanguage/Policy:Terms of Use">Terms of Use</a> and <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy" class="extiw" title="foundation:Special:MyLanguage/Policy:Privacy policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a rel="nofollow" class="external text" href="https://wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Linked_list&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/static/images/footer/wikimedia-button.svg" width="84" height="29"><img src="/static/images/footer/wikimedia.svg" width="25" height="25" alt="Wikimedia Foundation" lang="en" loading="lazy"></picture></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/w/resources/assets/poweredby_mediawiki.svg" width="88" height="31"><img src="/w/resources/assets/mediawiki_compact.svg" alt="Powered by MediaWiki" lang="en" width="25" height="25" loading="lazy"></picture></a></li> </ul> </footer> </div> </div> </div> <div class="vector-header-container vector-sticky-header-container"> <div id="vector-sticky-header" class="vector-sticky-header"> <div class="vector-sticky-header-start"> <div class="vector-sticky-header-icon-start vector-button-flush-left vector-button-flush-right" aria-hidden="true"> <button class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-sticky-header-search-toggle" tabindex="-1" data-event-name="ui.vector-sticky-search-form.icon"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </button> </div> <div role="search" class="vector-search-box-vue vector-search-box-show-thumbnail vector-search-box"> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail"> <form action="/w/index.php" id="vector-sticky-search-form" class="cdx-search-input cdx-search-input--has-end-button"> <div class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia"> <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <div class="vector-sticky-header-context-bar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-sticky-header-toc" class="vector-dropdown mw-portlet mw-portlet-sticky-header-toc vector-sticky-header-toc vector-button-flush-left" > <input type="checkbox" id="vector-sticky-header-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-sticky-header-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-sticky-header-toc-label" for="vector-sticky-header-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-sticky-header-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div class="vector-sticky-header-context-bar-primary" aria-hidden="true" ><span class="mw-page-title-main">Linked list</span></div> </div> </div> <div class="vector-sticky-header-end" aria-hidden="true"> <div class="vector-sticky-header-icons"> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-talk-sticky-header" tabindex="-1" data-event-name="talk-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbles mw-ui-icon-wikimedia-speechBubbles"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-subject-sticky-header" tabindex="-1" data-event-name="subject-sticky-header"><span class="vector-icon mw-ui-icon-article mw-ui-icon-wikimedia-article"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-history-sticky-header" tabindex="-1" data-event-name="history-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-history mw-ui-icon-wikimedia-wikimedia-history"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only mw-watchlink" id="ca-watchstar-sticky-header" tabindex="-1" data-event-name="watch-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-star mw-ui-icon-wikimedia-wikimedia-star"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-edit-sticky-header" tabindex="-1" data-event-name="wikitext-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-wikiText mw-ui-icon-wikimedia-wikimedia-wikiText"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-ve-edit-sticky-header" tabindex="-1" data-event-name="ve-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-edit mw-ui-icon-wikimedia-wikimedia-edit"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-viewsource-sticky-header" tabindex="-1" data-event-name="ve-edit-protected-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-editLock mw-ui-icon-wikimedia-wikimedia-editLock"></span> <span></span> </a> </div> <div class="vector-sticky-header-buttons"> <button class="cdx-button cdx-button--weight-quiet mw-interlanguage-selector" id="p-lang-btn-sticky-header" tabindex="-1" data-event-name="ui.dropdown-p-lang-btn-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-language mw-ui-icon-wikimedia-wikimedia-language"></span> <span>44 languages</span> </button> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive" id="ca-addsection-sticky-header" tabindex="-1" data-event-name="addsection-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbleAdd-progressive mw-ui-icon-wikimedia-speechBubbleAdd-progressive"></span> <span>Add topic</span> </a> </div> <div class="vector-sticky-header-icon-end"> <div class="vector-user-links"> </div> </div> </div> </div> </div> <div class="mw-portlet mw-portlet-dock-bottom emptyPortlet" id="p-dock-bottom"> <ul> </ul> </div> <script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.eqiad.main-8669bc5c8-5q8p5","wgBackendResponseTime":254,"wgPageParseReport":{"limitreport":{"cputime":"0.634","walltime":"0.841","ppvisitednodes":{"value":2486,"limit":1000000},"postexpandincludesize":{"value":74860,"limit":2097152},"templateargumentsize":{"value":2485,"limit":2097152},"expansiondepth":{"value":13,"limit":100},"expensivefunctioncount":{"value":8,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":87472,"limit":5000000},"entityaccesscount":{"value":1,"limit":400},"timingprofile":["100.00% 673.805 1 -total"," 29.65% 199.776 2 Template:Reflist"," 25.95% 174.869 10 Template:Cite_book"," 15.23% 102.592 1 Template:Data_structures"," 14.84% 100.024 1 Template:Navbox"," 10.00% 67.367 1 Template:Commons_category"," 9.80% 66.065 1 Template:Short_description"," 9.66% 65.101 1 Template:Sister_project"," 9.40% 63.358 1 Template:Side_box"," 8.83% 59.474 1 Template:More_footnotes_needed"]},"scribunto":{"limitreport-timeusage":{"value":"0.391","limit":"10.000"},"limitreport-memusage":{"value":6591718,"limit":52428800}},"cachereport":{"origin":"mw-web.eqiad.main-8669bc5c8-2m9bx","timestamp":"20250318155436","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Linked list","url":"https:\/\/en.wikipedia.org\/wiki\/Linked_list","sameAs":"http:\/\/www.wikidata.org\/entity\/Q7003418","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q7003418","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2001-09-27T05:52:51Z","dateModified":"2025-01-18T01:21:46Z","headline":"data structure which is a linear collection of data elements, called nodes, each pointing to the next node by means of a pointer"}</script> </body> </html>