CINXE.COM

Heap (data structure) - Wikipedia

<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-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-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Heap (data structure) - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-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-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":"3decc464-43f0-4d65-a994-f87a9028a170","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Heap_(data_structure)","wgTitle":"Heap (data structure)","wgCurRevisionId":1259776930,"wgRevisionId":1259776930,"wgArticleId":13996,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description is different from Wikidata","Commons category link is on Wikidata","Heaps (data structures)"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Heap_(data_structure)","wgRelevantArticleId":13996,"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":20000,"wgRelatedArticlesCompat":[],"wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q274089","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.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","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.cite.ux-enhancements","mediawiki.page.media","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.quicksurveys.init","ext.growthExperiments.SuggestedEditSession","wikibase.sidebar.tracking"];</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&amp;modules=ext.cite.styles%7Cext.math.styles%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediaBadges%7Cext.wikimediamessages.styles%7Cjquery.makeCollapsible.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&amp;only=styles&amp;skin=vector-2022"> <script async="" src="/w/load.php?lang=en&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=site.styles&amp;only=styles&amp;skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <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 property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Max-Heap-new.svg/1200px-Max-Heap-new.svg.png"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="1439"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Max-Heap-new.svg/800px-Max-Heap-new.svg.png"> <meta property="og:image:width" content="800"> <meta property="og:image:height" content="959"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Max-Heap-new.svg/640px-Max-Heap-new.svg.png"> <meta property="og:image:width" content="640"> <meta property="og:image:height" content="768"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Heap (data structure) - 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/Heap_(data_structure)"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Heap_(data_structure)&amp;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/Heap_(data_structure)"> <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&amp;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-Heap_data_structure rootpage-Heap_data_structure 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" > <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> </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&#039;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/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_en.wikipedia.org&amp;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&amp;returnto=Heap+%28data+structure%29" 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&amp;returnto=Heap+%28data+structure%29" title="You&#039;re encouraged to log in; however, it&#039;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/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_en.wikipedia.org&amp;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&amp;returnto=Heap+%28data+structure%29" 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&amp;returnto=Heap+%28data+structure%29" title="You&#039;re encouraged to log in; however, it&#039;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-Operations" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Operations"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Operations</span> </div> </a> <ul id="toc-Operations-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Implementation" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Implementation"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Implementation</span> </div> </a> <ul id="toc-Implementation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Variants" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Variants"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Variants</span> </div> </a> <ul id="toc-Variants-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Comparison_of_theoretic_bounds_for_variants" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Comparison_of_theoretic_bounds_for_variants"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Comparison of theoretic bounds for variants</span> </div> </a> <ul id="toc-Comparison_of_theoretic_bounds_for_variants-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Applications" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Applications"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Applications</span> </div> </a> <ul id="toc-Applications-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Programming_language_implementations" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Programming_language_implementations"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Programming language implementations</span> </div> </a> <ul id="toc-Programming_language_implementations-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</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" > <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">Heap (data structure)</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 41 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-41" 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">41 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%83%D9%88%D9%85%D8%A9_(%D9%87%D9%8A%D8%A7%D9%83%D9%84_%D8%A8%D9%8A%D8%A7%D9%86%D8%A7%D8%AA)" 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/Qalaq_(veril%C9%99nl%C9%99r_strukturu)" title="Qalaq (verilənlər strukturu) – Azerbaijani" lang="az" hreflang="az" data-title="Qalaq (verilənlər strukturu)" 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-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Heap_(estructura_de_dades)" title="Heap (estructura de dades) – Catalan" lang="ca" hreflang="ca" data-title="Heap (estructura de dades)" 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/Halda_(datov%C3%A1_struktura)" title="Halda (datová struktura) – Czech" lang="cs" hreflang="cs" data-title="Halda (datová struktura)" 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/Hob_(datastruktur)" title="Hob (datastruktur) – Danish" lang="da" hreflang="da" data-title="Hob (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/Heap_(Datenstruktur)" title="Heap (Datenstruktur) – German" lang="de" hreflang="de" data-title="Heap (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/Kuhi_(informaatika)" title="Kuhi (informaatika) – Estonian" lang="et" hreflang="et" data-title="Kuhi (informaatika)" 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/Mont%C3%ADculo_(inform%C3%A1tica)" title="Montículo (informática) – Spanish" lang="es" hreflang="es" data-title="Montículo (informática)" 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%87%D8%B1%D9%85_(%D8%B3%D8%A7%D8%AE%D8%AA%D9%85%D8%A7%D9%86_%D8%AF%D8%A7%D8%AF%D9%87)" 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/Tas_(informatique)" title="Tas (informatique) – French" lang="fr" hreflang="fr" data-title="Tas (informatique)" 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/%ED%9E%99_(%EC%9E%90%EB%A3%8C_%EA%B5%AC%EC%A1%B0)" 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-hi mw-list-item"><a href="https://hi.wikipedia.org/wiki/%E0%A4%B9%E0%A5%80%E0%A4%AA" title="हीप – Hindi" lang="hi" hreflang="hi" data-title="हीप" data-language-autonym="हिन्दी" data-language-local-name="Hindi" class="interlanguage-link-target"><span>हिन्दी</span></a></li><li class="interlanguage-link interwiki-id mw-list-item"><a href="https://id.wikipedia.org/wiki/Heap_(struktur_data)" title="Heap (struktur data) – Indonesian" lang="id" hreflang="id" data-title="Heap (struktur data)" 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/Hr%C3%BAga_(t%C3%B6lvunarfr%C3%A6%C3%B0i)" title="Hrúga (tölvunarfræði) – Icelandic" lang="is" hreflang="is" data-title="Hrúga (tölvunarfræði)" 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/Heap_(struttura_dati)" title="Heap (struttura dati) – Italian" lang="it" hreflang="it" data-title="Heap (struttura dati)" 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%A2%D7%A8%D7%99%D7%9E%D7%94" 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-la mw-list-item"><a href="https://la.wikipedia.org/wiki/Cumulus_(scientia_computatralis)" title="Cumulus (scientia computatralis) – Latin" lang="la" hreflang="la" data-title="Cumulus (scientia computatralis)" data-language-autonym="Latina" data-language-local-name="Latin" class="interlanguage-link-target"><span>Latina</span></a></li><li class="interlanguage-link interwiki-lt mw-list-item"><a href="https://lt.wikipedia.org/wiki/Kr%C5%ABva" title="Krūva – Lithuanian" lang="lt" hreflang="lt" data-title="Krūva" 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/Heap_(strutura_di_dacc)" title="Heap (strutura di dacc) – Lombard" lang="lmo" hreflang="lmo" data-title="Heap (strutura di dacc)" 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/Kupac_(adatszerkezet)" title="Kupac (adatszerkezet) – Hungarian" lang="hu" hreflang="hu" data-title="Kupac (adatszerkezet)" 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%B9%E0%B5%80%E0%B4%AA%E0%B5%8D_(%E0%B4%A1%E0%B4%BE%E0%B4%B1%E0%B5%8D%E0%B4%B1%E0%B4%BE_%E0%B4%B8%E0%B5%8D%E0%B4%9F%E0%B5%8D%E0%B4%B0%E0%B4%95%E0%B5%8D%E2%80%8C%E0%B4%9A%E0%B5%8D%E0%B4%9A%E0%B5%BC)" 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-mn mw-list-item"><a href="https://mn.wikipedia.org/wiki/%D0%9E%D0%B2%D0%BE%D0%BE%D0%BB%D0%B3%D0%BE" title="Овоолго – Mongolian" lang="mn" hreflang="mn" data-title="Овоолго" data-language-autonym="Монгол" data-language-local-name="Mongolian" class="interlanguage-link-target"><span>Монгол</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Heap" title="Heap – Dutch" lang="nl" hreflang="nl" data-title="Heap" 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/%E3%83%92%E3%83%BC%E3%83%97" 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/Heap" title="Heap – Norwegian Bokmål" lang="nb" hreflang="nb" data-title="Heap" 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/Kopiec_(informatyka)" title="Kopiec (informatyka) – Polish" lang="pl" hreflang="pl" data-title="Kopiec (informatyka)" 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/Heap" title="Heap – Portuguese" lang="pt" hreflang="pt" data-title="Heap" 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%9A%D1%83%D1%87%D0%B0_(%D1%81%D1%82%D1%80%D1%83%D0%BA%D1%82%D1%83%D1%80%D0%B0_%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85)" 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/Heap_(data_structure)" title="Heap (data structure) – Simple English" lang="en-simple" hreflang="en-simple" data-title="Heap (data structure)" 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-sk mw-list-item"><a href="https://sk.wikipedia.org/wiki/Halda_(d%C3%A1tov%C3%A1_%C5%A1trukt%C3%BAra)" title="Halda (dátová štruktúra) – Slovak" lang="sk" hreflang="sk" data-title="Halda (dátová štruktúra)" data-language-autonym="Slovenčina" data-language-local-name="Slovak" class="interlanguage-link-target"><span>Slovenčina</span></a></li><li class="interlanguage-link interwiki-sl mw-list-item"><a href="https://sl.wikipedia.org/wiki/Kopica" title="Kopica – Slovenian" lang="sl" hreflang="sl" data-title="Kopica" 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-ckb mw-list-item"><a href="https://ckb.wikipedia.org/wiki/%DA%BE%DB%8C%D9%BE_(%D9%BE%DB%8E%DA%A9%DA%BE%D8%A7%D8%AA%DB%95%DB%8C_%D8%AF%D8%B1%D8%A7%D9%88%DB%95)" title="ھیپ (پێکھاتەی دراوە) – Central Kurdish" lang="ckb" hreflang="ckb" data-title="ھیپ (پێکھاتەی دراوە)" data-language-autonym="کوردی" data-language-local-name="Central Kurdish" class="interlanguage-link-target"><span>کوردی</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/Hip_(struktura_podataka)" title="Hip (struktura podataka) – Serbian" lang="sr" hreflang="sr" data-title="Hip (struktura podataka)" 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/Keko_(tietorakenne)" title="Keko (tietorakenne) – Finnish" lang="fi" hreflang="fi" data-title="Keko (tietorakenne)" 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/Heap_(datastruktur)" title="Heap (datastruktur) – Swedish" lang="sv" hreflang="sv" data-title="Heap (datastruktur)" data-language-autonym="Svenska" data-language-local-name="Swedish" class="interlanguage-link-target"><span>Svenska</span></a></li><li class="interlanguage-link interwiki-th mw-list-item"><a href="https://th.wikipedia.org/wiki/%E0%B8%AE%E0%B8%B5%E0%B8%9B_(%E0%B9%82%E0%B8%84%E0%B8%A3%E0%B8%87%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%B9%E0%B8%A5)" 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/%C3%96bek_(veri_yap%C4%B1s%C4%B1)" title="Öbek (veri yapısı) – Turkish" lang="tr" hreflang="tr" data-title="Öbek (veri yapısı)" 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%9A%D1%83%D0%BF%D0%B0_(%D1%81%D1%82%D1%80%D1%83%D0%BA%D1%82%D1%83%D1%80%D0%B0_%D0%B4%D0%B0%D0%BD%D0%B8%D1%85)" 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-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/%C4%90%E1%BB%91ng_(c%E1%BA%A5u_tr%C3%BAc_d%E1%BB%AF_li%E1%BB%87u)" title="Đống (cấu trúc dữ liệu) – Vietnamese" lang="vi" hreflang="vi" data-title="Đống (cấu trúc dữ liệu)" 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/%E5%A0%86%E7%A9%8D%E6%A8%B9" 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/%E5%A0%86%E7%A9%8D" 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/Q274089#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/Heap_(data_structure)" 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:Heap_(data_structure)" 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/Heap_(data_structure)"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Heap_(data_structure)&amp;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=Heap_(data_structure)&amp;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/Heap_(data_structure)"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Heap_(data_structure)&amp;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=Heap_(data_structure)&amp;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/Heap_(data_structure)" 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/Heap_(data_structure)" 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="/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Heap_(data_structure)&amp;oldid=1259776930" 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=Heap_(data_structure)&amp;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&amp;page=Heap_%28data_structure%29&amp;id=1259776930&amp;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&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHeap_%28data_structure%29"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHeap_%28data_structure%29"><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&amp;page=Heap_%28data_structure%29&amp;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=Heap_(data_structure)&amp;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:Heap_data_structures" 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/Q274089" 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">Computer science data structure</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">For the memory heap (in low-level computer programming), which is unrelated to this data structure, see <a href="/wiki/C_dynamic_memory_allocation" title="C dynamic memory allocation">C dynamic memory allocation</a>.</div> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Max-Heap-new.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Max-Heap-new.svg/220px-Max-Heap-new.svg.png" decoding="async" width="220" height="264" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Max-Heap-new.svg/330px-Max-Heap-new.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Max-Heap-new.svg/440px-Max-Heap-new.svg.png 2x" data-file-width="512" data-file-height="614" /></a><figcaption>Example of a <a href="/wiki/Binary_tree" title="Binary tree">binary</a> max-heap with node keys being integers between 1 and 100</figcaption></figure> <p>In <a href="/wiki/Computer_science" title="Computer science">computer science</a>, a <b>heap</b> is a <a href="/wiki/Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">tree</a>-based <a href="/wiki/Data_structure" title="Data structure">data structure</a> that satisfies the <b>heap property</b>: In a <i>max heap</i>, for any given <a href="/wiki/Node_(computer_science)" title="Node (computer science)">node</a> C, if P is the parent node of C, then the <i>key</i> (the <i>value</i>) of P is greater than or equal to the key of C. In a <i>min heap</i>, the key of P is less than or equal to the key of C.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> The node at the "top" of the heap (with no parents) is called the <i>root</i> node. </p><p>The heap is one maximally efficient implementation of an <a href="/wiki/Abstract_data_type" title="Abstract data type">abstract data type</a> called a <a href="/wiki/Priority_queue" title="Priority queue">priority queue</a>, and in fact, priority queues are often referred to as "heaps", regardless of how they may be implemented. In a heap, the highest (or lowest) priority element is always stored at the root. However, a heap is not a sorted structure; it can be regarded as being partially ordered. A heap is a useful data structure when it is necessary to repeatedly remove the object with the highest (or lowest) priority, or when insertions need to be interspersed with removals of the root node. </p><p>A common implementation of a heap is the <a href="/wiki/Binary_heap" title="Binary heap">binary heap</a>, in which the tree is a <a href="/wiki/Binary_tree#Types_of_binary_trees" title="Binary tree">complete</a><sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup> binary tree (see figure). The heap data structure, specifically the binary heap, was introduced by <a href="/wiki/J._W._J._Williams" title="J. W. J. Williams">J. W. J. Williams</a> in 1964, as a data structure for the <a href="/wiki/Heapsort" title="Heapsort">heapsort</a> sorting algorithm.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>3<span class="cite-bracket">&#93;</span></a></sup> Heaps are also crucial in several efficient <a href="/wiki/Graph_algorithms" class="mw-redirect" title="Graph algorithms">graph algorithms</a> such as <a href="/wiki/Dijkstra%27s_algorithm" title="Dijkstra&#39;s algorithm">Dijkstra's algorithm</a>. When a heap is a complete binary tree, it has the smallest possible height—a heap with <i>N</i> nodes and <i>a</i> branches for each node always has log<sub><i>a</i></sub> <i>N</i> height. </p><p>Note that, as shown in the graphic, there is no implied ordering between siblings or cousins and no implied sequence for an <a href="/wiki/Inorder_traversal" class="mw-redirect" title="Inorder traversal">in-order traversal</a> (as there would be in, e.g., a <a href="/wiki/Binary_search_tree" title="Binary search tree">binary search tree</a>). The heap relation mentioned above applies only between nodes and their parents, grandparents. The maximum number of children each node can have depends on the type of heap. </p><p>Heaps are typically constructed in-place in the same array where the elements are stored, with their structure being implicit in the access pattern of the operations. Heaps differ in this way from other data structures with similar or in some cases better theoretic bounds such as <a href="/wiki/Radix_tree" title="Radix tree">Radix trees</a> in that they require no additional memory beyond that used for storing the keys. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Operations">Operations</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Heap_(data_structure)&amp;action=edit&amp;section=1" title="Edit section: Operations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The common operations involving heaps are: </p> <dl><dt>Basic</dt></dl> <ul><li><i>find-max</i> (or <i>find-min</i>): find a maximum item of a max-heap, or a minimum item of a min-heap, respectively (a.k.a. <i><a href="/wiki/Peek_(data_type_operation)" title="Peek (data type operation)">peek</a></i>)</li> <li><i>insert</i>: adding a new key to the heap (a.k.a., <i>push</i><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>4<span class="cite-bracket">&#93;</span></a></sup>)</li> <li><i>extract-max</i> (or <i>extract-min</i>): returns the node of maximum value from a max heap [or minimum value from a min heap] after removing it from the heap (a.k.a., <i>pop</i><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">&#91;</span>5<span class="cite-bracket">&#93;</span></a></sup>)</li> <li><i>delete-max</i> (or <i>delete-min</i>): removing the root node of a max heap (or min heap), respectively</li> <li><i>replace</i>: pop root and push a new key. This is more efficient than a pop followed by a push, since it only needs to balance once, not twice, and is appropriate for fixed-size heaps.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">&#91;</span>6<span class="cite-bracket">&#93;</span></a></sup></li></ul> <dl><dt>Creation</dt></dl> <ul><li><i>create-heap</i>: create an empty heap</li> <li><i>heapify</i>: create a heap out of given array of elements</li> <li><i>merge</i> (<i>union</i>): joining two heaps to form a valid new heap containing all the elements of both, preserving the original heaps.</li> <li><i>meld</i>: joining two heaps to form a valid new heap containing all the elements of both, destroying the original heaps.</li></ul> <dl><dt>Inspection</dt></dl> <ul><li><i>size</i>: return the number of items in the heap.</li> <li><i>is-empty</i>: return true if the heap is empty, false otherwise.</li></ul> <dl><dt>Internal</dt></dl> <ul><li><i>increase-key</i> or <i>decrease-key</i>: updating a key within a max- or min-heap, respectively</li> <li><i>delete</i>: delete an arbitrary node (followed by moving last node and sifting to maintain heap)</li> <li><i>sift-up</i>: move a node up in the tree, as long as needed; used to restore heap condition after insertion. Called "sift" because node moves up the tree until it reaches the correct level, as in a <a href="/wiki/Sieve" title="Sieve">sieve</a>.</li> <li><i>sift-down</i>: move a node down in the tree, similar to sift-up; used to restore heap condition after deletion or replacement.</li></ul> <div class="mw-heading mw-heading2"><h2 id="Implementation">Implementation</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Heap_(data_structure)&amp;action=edit&amp;section=2" title="Edit section: Implementation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Heaps are usually implemented with an <a href="/wiki/Array_data_structure" class="mw-redirect" title="Array data structure">array</a>, as follows: </p> <ul><li>Each element in the array represents a node of the heap, and</li> <li>The parent / child relationship is <a href="/wiki/Implicit_data_structure" title="Implicit data structure">defined implicitly</a> by the elements' indices in the array.</li></ul> <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Heap-as-array.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Heap-as-array.svg/330px-Heap-as-array.svg.png" decoding="async" width="330" height="124" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Heap-as-array.svg/495px-Heap-as-array.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Heap-as-array.svg/660px-Heap-as-array.svg.png 2x" data-file-width="603" data-file-height="227" /></a><figcaption>Example of a complete binary max-heap with node keys being integers from 1 to 100 and how it would be stored in an array.</figcaption></figure> <p>For a <a href="/wiki/Binary_heap" title="Binary heap">binary heap</a>, in the array, the first index contains the root element. The next two indices of the array contain the root's children. The next four indices contain the four children of the root's two child nodes, and so on. Therefore, given a node at index <span class="texhtml mvar" style="font-style:italic;">i</span>, its children are at indices <span class="nowrap">&#8288;<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 2i+1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mn>2</mn> <mi>i</mi> <mo>+</mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2i+1}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f077f73c2ecdf3c6e29a120f948a7255c0a65da1" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:5.968ex; height:2.343ex;" alt="{\displaystyle 2i+1}"></span>&#8288;</span> and <span class="nowrap">&#8288;<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 2i+2}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mn>2</mn> <mi>i</mi> <mo>+</mo> <mn>2</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2i+2}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a756deaef520ee23fe2b1232c90957f55ec9d92b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:5.968ex; height:2.343ex;" alt="{\displaystyle 2i+2}"></span>&#8288;</span>, and its parent is at index <span class="texhtml">⌊(<i>i</i>−1)/2⌋</span>. This simple indexing scheme makes it efficient to move "up" or "down" the tree. </p><p>Balancing a heap is done by sift-up or sift-down operations (swapping elements which are out of order). As we can build a heap from an array without requiring extra memory (for the nodes, for example), <a href="/wiki/Heapsort" title="Heapsort">heapsort</a> can be used to sort an array in-place. </p><p>After an element is inserted into or deleted from a heap, the heap property may be violated, and the heap must be re-balanced by swapping elements within the array. </p><p>Although different types of heaps implement the operations differently, the most common way is as follows: </p> <ul><li><b>Insertion:</b> Add the new element at the end of the heap, in the first available free space. If this will violate the heap property, sift up the new element (<i>swim</i> operation) until the heap property has been reestablished.</li> <li><b>Extraction:</b> Remove the root and insert the last element of the heap in the root. If this will violate the heap property, sift down the new root (<i>sink</i> operation) to reestablish the heap property.</li> <li><b>Replacement:</b> Remove the root and put the <i>new</i> element in the root and sift down. When compared to extraction followed by insertion, this avoids a sift up step.</li></ul> <p>Construction of a binary (or <i>d</i>-ary) heap out of a given array of elements may be performed in linear time using the classic <a href="/wiki/Heapsort#Variations" title="Heapsort">Floyd algorithm</a>, with the worst-case number of comparisons equal to 2<i>N</i> − 2<i>s</i><sub>2</sub>(<i>N</i>) − <i>e</i><sub>2</sub>(<i>N</i>) (for a binary heap), where <i>s</i><sub>2</sub>(<i>N</i>) is the sum of all digits of the binary representation of <i>N</i> and <i>e</i><sub>2</sub>(<i>N</i>) is the exponent of 2 in the prime factorization of <i>N</i>.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">&#91;</span>7<span class="cite-bracket">&#93;</span></a></sup> This is faster than a sequence of consecutive insertions into an originally empty heap, which is log-linear.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">&#91;</span>a<span class="cite-bracket">&#93;</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Variants">Variants</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Heap_(data_structure)&amp;action=edit&amp;section=3" title="Edit section: Variants"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1184024115">.mw-parser-output .div-col{margin-top:0.3em;column-width:30em}.mw-parser-output .div-col-small{font-size:90%}.mw-parser-output .div-col-rules{column-rule:1px solid #aaa}.mw-parser-output .div-col dl,.mw-parser-output .div-col ol,.mw-parser-output .div-col ul{margin-top:0}.mw-parser-output .div-col li,.mw-parser-output .div-col dd{page-break-inside:avoid;break-inside:avoid-column}</style><div class="div-col" style="column-width: 10em;"> <ul><li><a href="/wiki/2%E2%80%933_heap" title="2–3 heap">2–3 heap</a></li> <li><a href="/wiki/B-heap" title="B-heap">B-heap</a></li> <li><a href="/wiki/Beap" title="Beap">Beap</a></li> <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/Brodal_queue" title="Brodal queue">Brodal queue</a></li> <li><a href="/wiki/D-ary_heap" title="D-ary heap"><i>d</i>-ary heap</a></li> <li><a href="/wiki/Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a></li> <li><a href="/wiki/K-D_Heap" class="mw-redirect" title="K-D Heap">K-D Heap</a></li> <li><a href="/w/index.php?title=Leaf_heap&amp;action=edit&amp;redlink=1" class="new" title="Leaf heap (page does not exist)">Leaf heap</a></li> <li><a href="/wiki/Leftist_tree" title="Leftist tree">Leftist heap</a></li> <li><a href="/wiki/Skew_binomial_heap" title="Skew binomial heap">Skew binomial heap</a></li> <li><a href="/wiki/Strict_Fibonacci_heap" title="Strict Fibonacci heap">Strict Fibonacci heap</a></li> <li><a href="/wiki/Min-max_heap" title="Min-max heap">Min-max heap</a></li> <li><a href="/wiki/Pairing_heap" title="Pairing heap">Pairing heap</a></li> <li><a href="/wiki/Radix_heap" title="Radix heap">Radix heap</a></li> <li><a href="/wiki/Randomized_meldable_heap" title="Randomized meldable heap">Randomized meldable heap</a></li> <li><a href="/wiki/Skew_heap" title="Skew heap">Skew heap</a></li> <li><a href="/wiki/Soft_heap" title="Soft heap">Soft heap</a></li> <li><a href="/wiki/Ternary_heap" class="mw-redirect" title="Ternary heap">Ternary heap</a></li> <li><a href="/wiki/Treap" title="Treap">Treap</a></li> <li><a href="/wiki/Weak_heap" title="Weak heap">Weak heap</a></li></ul> </div> <div class="mw-heading mw-heading2"><h2 id="Comparison_of_theoretic_bounds_for_variants">Comparison of theoretic bounds for variants</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Heap_(data_structure)&amp;action=edit&amp;section=4" title="Edit section: Comparison of theoretic bounds for variants"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Here are <a href="/wiki/Computational_complexity_theory" title="Computational complexity theory">time complexities</a><sup id="cite_ref-CLRS_9-0" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup> of various heap data structures. The abbreviation <abbr title="amortized complexity">am.</abbr> indicates that the given complexity is amortized, otherwise it is a worst-case complexity. For the meaning of "<i>O</i>(<i>f</i>)" and "<i>Θ</i>(<i>f</i>)" see <a href="/wiki/Big_O_notation" title="Big O notation">Big O notation</a>. Names of operations assume a max-heap. </p> <table class="wikitable"> <tbody><tr> <th>Operation </th> <th>find-max </th> <th>delete-max </th> <th>increase-key </th> <th>insert </th> <th>meld </th> <th>make-heap<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">&#91;</span>b<span class="cite-bracket">&#93;</span></a></sup> </th></tr> <tr> <th><a href="/wiki/Binary_heap" title="Binary heap">Binary</a><sup id="cite_ref-CLRS_9-1" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffdddd"><i>Θ</i>(<i>n</i>) </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/Skew_heap" title="Skew heap">Skew</a><sup id="cite_ref-sleator-tarjan-skew_10-1" class="reference"><a href="#cite_note-sleator-tarjan-skew-10"><span class="cite-bracket">&#91;</span>9<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td></tr> <tr> <th><a href="/wiki/Leftist_tree" title="Leftist tree">Leftist</a><sup id="cite_ref-tarjan-leftist_11-1" class="reference"><a href="#cite_note-tarjan-leftist-11"><span class="cite-bracket">&#91;</span>10<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/Binomial_heap" title="Binomial heap">Binomial</a><sup id="cite_ref-CLRS_9-2" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">&#91;</span>12<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>)<sup id="cite_ref-bootstrap-meld_15-0" class="reference"><a href="#cite_note-bootstrap-meld-15"><span class="cite-bracket">&#91;</span>c<span class="cite-bracket">&#93;</span></a></sup> </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/Skew_binomial_heap" title="Skew binomial heap">Skew binomial</a><sup id="cite_ref-brodal-okasaki_16-0" class="reference"><a href="#cite_note-brodal-okasaki-16"><span class="cite-bracket">&#91;</span>13<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>)<sup id="cite_ref-bootstrap-meld_15-1" class="reference"><a href="#cite_note-bootstrap-meld-15"><span class="cite-bracket">&#91;</span>c<span class="cite-bracket">&#93;</span></a></sup> </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/2%E2%80%933_heap" title="2–3 heap">2–3 heap</a><sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">&#91;</span>15<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>)<sup id="cite_ref-bootstrap-meld_15-2" class="reference"><a href="#cite_note-bootstrap-meld-15"><span class="cite-bracket">&#91;</span>c<span class="cite-bracket">&#93;</span></a></sup> </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/Skew_heap" title="Skew heap">Bottom-up skew</a><sup id="cite_ref-sleator-tarjan-skew_10-2" class="reference"><a href="#cite_note-sleator-tarjan-skew-10"><span class="cite-bracket">&#91;</span>9<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td></tr> <tr> <th><a href="/wiki/Pairing_heap" title="Pairing heap">Pairing</a><sup id="cite_ref-Iacono_19-0" class="reference"><a href="#cite_note-Iacono-19"><span class="cite-bracket">&#91;</span>16<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ffffdd"><i>o</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr><sup id="cite_ref-pairingdecreasekey_22-0" class="reference"><a href="#cite_note-pairingdecreasekey-22"><span class="cite-bracket">&#91;</span>d<span class="cite-bracket">&#93;</span></a></sup> </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/w/index.php?title=Rank-pairing_heap&amp;action=edit&amp;redlink=1" class="new" title="Rank-pairing heap (page does not exist)">Rank-pairing</a><sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">&#91;</span>19<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/Fibonacci_heap" title="Fibonacci heap">Fibonacci</a><sup id="cite_ref-CLRS_9-3" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">&#91;</span>8<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-Fredman_And_Tarjan_24-0" class="reference"><a href="#cite_note-Fredman_And_Tarjan-24"><span class="cite-bracket">&#91;</span>20<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>O</i>(log&#160;<i>n</i>) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr> </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/Strict_Fibonacci_heap" title="Strict Fibonacci heap">Strict Fibonacci</a><sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">&#91;</span>21<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-optimum_26-0" class="reference"><a href="#cite_note-optimum-26"><span class="cite-bracket">&#91;</span>e<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) </td></tr> <tr> <th><a href="/wiki/Brodal_queue" title="Brodal queue">Brodal</a><sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">&#91;</span>22<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-optimum_26-1" class="reference"><a href="#cite_note-optimum-26"><span class="cite-bracket">&#91;</span>e<span class="cite-bracket">&#93;</span></a></sup> </th> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ffffdd"><i>Θ</i>(log&#160;<i>n</i>) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(1) </td> <td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">&#91;</span>23<span class="cite-bracket">&#93;</span></a></sup> </td></tr></tbody></table> <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 reflist-lower-alpha"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">Each insertion takes O(log(<i>k</i>)) in the existing size of the heap, thus <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 \sum _{k=1}^{n}O(\log k)}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <munderover> <mo>&#x2211;<!-- ∑ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mi>k</mi> <mo>=</mo> <mn>1</mn> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </munderover> <mi>O</mi> <mo stretchy="false">(</mo> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>k</mi> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sum _{k=1}^{n}O(\log k)}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/57ee533ff7ef5300fd717d9230ca17a135c24df4" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.005ex; width:11.895ex; height:6.843ex;" alt="{\displaystyle \sum _{k=1}^{n}O(\log k)}"></span>. Since <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 \log n/2=(\log n)-1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>n</mi> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <mn>2</mn> <mo>=</mo> <mo stretchy="false">(</mo> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>n</mi> <mo stretchy="false">)</mo> <mo>&#x2212;<!-- − --></mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \log n/2=(\log n)-1}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4dc03c817e6d65fe0ea9dffce246278943db343e" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:20.743ex; height:2.843ex;" alt="{\displaystyle \log n/2=(\log n)-1}"></span>, a constant factor (half) of these insertions are within a constant factor of the maximum, so asymptotically we can assume <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=n}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>k</mi> <mo>=</mo> <mi>n</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle k=n}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/c4b8cc6fcba0c0b24656b0fb33414d2e6cffb83c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.704ex; height:2.176ex;" alt="{\displaystyle k=n}"></span>; formally the time is <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 nO(\log n)-O(n)=O(n\log n)}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>n</mi> <mi>O</mi> <mo stretchy="false">(</mo> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>n</mi> <mo stretchy="false">)</mo> <mo>&#x2212;<!-- − --></mo> <mi>O</mi> <mo stretchy="false">(</mo> <mi>n</mi> <mo stretchy="false">)</mo> <mo>=</mo> <mi>O</mi> <mo stretchy="false">(</mo> <mi>n</mi> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>n</mi> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle nO(\log n)-O(n)=O(n\log n)}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d96da998a5bf48e66f5960204a4610d2d9e0a226" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:30.765ex; height:2.843ex;" alt="{\displaystyle nO(\log n)-O(n)=O(n\log n)}"></span>. This can also be readily seen from <a href="/wiki/Stirling%27s_approximation" title="Stirling&#39;s approximation">Stirling's approximation</a>.</span> </li> <li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><i>make-heap</i> is the operation of building a heap from a sequence of <i>n</i> unsorted elements. It can be done in <i>Θ</i>(<i>n</i>) time whenever <i>meld</i> runs in <i>O</i>(log&#160;<i>n</i>) time (where both complexities can be amortized).<sup id="cite_ref-sleator-tarjan-skew_10-0" class="reference"><a href="#cite_note-sleator-tarjan-skew-10"><span class="cite-bracket">&#91;</span>9<span class="cite-bracket">&#93;</span></a></sup><sup id="cite_ref-tarjan-leftist_11-0" class="reference"><a href="#cite_note-tarjan-leftist-11"><span class="cite-bracket">&#91;</span>10<span class="cite-bracket">&#93;</span></a></sup> Another algorithm achieves <i>Θ</i>(<i>n</i>) for binary heaps.<sup id="cite_ref-hayward-mcdiarmid-heap-build_12-0" class="reference"><a href="#cite_note-hayward-mcdiarmid-heap-build-12"><span class="cite-bracket">&#91;</span>11<span class="cite-bracket">&#93;</span></a></sup></span> </li> <li id="cite_note-bootstrap-meld-15"><span class="mw-cite-backlink">^ <a href="#cite_ref-bootstrap-meld_15-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-bootstrap-meld_15-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-bootstrap-meld_15-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text">For <a href="/wiki/Persistent_data_structure" title="Persistent data structure">persistent</a> heaps (not supporting <i>increase-key</i>), a generic transformation reduces the cost of <i>meld</i> to that of <i>insert</i>, while the new cost of <i>delete-max</i> is the sum of the old costs of <i>delete-max</i> and <i>meld</i>.<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">&#91;</span>14<span class="cite-bracket">&#93;</span></a></sup> Here, it makes <i>meld</i> run in <i>Θ</i>(1) time (amortized, if the cost of <i>insert</i> is) while <i>delete-max</i> still runs in <i>O</i>(log&#160;<i>n</i>). Applied to skew binomial heaps, it yields Brodal-Okasaki queues, persistent heaps with optimal worst-case complexities.<sup id="cite_ref-brodal-okasaki_16-1" class="reference"><a href="#cite_note-brodal-okasaki-16"><span class="cite-bracket">&#91;</span>13<span class="cite-bracket">&#93;</span></a></sup></span> </li> <li id="cite_note-pairingdecreasekey-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-pairingdecreasekey_22-0">^</a></b></span> <span class="reference-text">Lower bound 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 \Omega (\log \log n),}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi mathvariant="normal">&#x03A9;<!-- Ω --></mi> <mo stretchy="false">(</mo> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>n</mi> <mo stretchy="false">)</mo> <mo>,</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \Omega (\log \log n),}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/7caf8c32fbd99eed1338c02b7f7f1255f16ade36" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.247ex; height:2.843ex;" alt="{\displaystyle \Omega (\log \log n),}"></span><sup id="cite_ref-Fredman1999_20-0" class="reference"><a href="#cite_note-Fredman1999-20"><span class="cite-bracket">&#91;</span>17<span class="cite-bracket">&#93;</span></a></sup> upper bound 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(2^{2{\sqrt {\log \log n}}}).}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>O</mi> <mo stretchy="false">(</mo> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>log</mi> <mo>&#x2061;<!-- ⁡ --></mo> <mi>n</mi> </msqrt> </mrow> </mrow> </msup> <mo stretchy="false">)</mo> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle O(2^{2{\sqrt {\log \log n}}}).}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/45c772d2ec070e49a6438ea92b1c8dc764613c5e" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:14.052ex; height:3.509ex;" alt="{\displaystyle O(2^{2{\sqrt {\log \log n}}}).}"></span><sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">&#91;</span>18<span class="cite-bracket">&#93;</span></a></sup></span> </li> <li id="cite_note-optimum-26"><span class="mw-cite-backlink">^ <a href="#cite_ref-optimum_26-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-optimum_26-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">Brodal queues and strict Fibonacci heaps achieve optimal worst-case complexities for heaps. They were first described as imperative data structures. The Brodal-Okasaki queue is a <a href="/wiki/Persistent_data_structure" title="Persistent data structure">persistent</a> data structure achieving the same optimum, except that <i>increase-key</i> is not supported.</span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="Applications">Applications</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Heap_(data_structure)&amp;action=edit&amp;section=5" title="Edit section: Applications"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The heap data structure has many applications. </p> <ul><li><a href="/wiki/Heapsort" title="Heapsort">Heapsort</a>: One of the best sorting methods being in-place and with no quadratic worst-case scenarios.</li> <li><a href="/wiki/Selection_algorithm" title="Selection algorithm">Selection algorithms</a>: A heap allows access to the min or max element in constant time, and other selections (such as median or kth-element) can be done in sub-linear time on data that is in a heap.<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">&#91;</span>24<span class="cite-bracket">&#93;</span></a></sup></li> <li><a href="/wiki/List_of_algorithms#Graph_algorithms" title="List of algorithms">Graph algorithms</a>: By using heaps as internal traversal data structures, run time will be reduced by polynomial order. Examples of such problems are <a href="/wiki/Prim%27s_algorithm" title="Prim&#39;s algorithm">Prim's minimal-spanning-tree algorithm</a> and <a href="/wiki/Dijkstra%27s_algorithm" title="Dijkstra&#39;s algorithm">Dijkstra's shortest-path algorithm</a>.</li> <li><a href="/wiki/Priority_queue" title="Priority queue">Priority queue</a>: A priority queue is an abstract concept like "a list" or "a map"; just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods.</li> <li><a href="/wiki/K-way_merge_algorithm" title="K-way merge algorithm">K-way merge</a>: A heap data structure is useful to merge many already-sorted input streams into a single sorted output stream. Examples of the need for merging include external sorting and streaming results from distributed data such as a log structured merge tree. The inner loop is obtaining the min element, replacing with the next element for the corresponding input stream, then doing a sift-down heap operation. (Alternatively the replace function.) (Using extract-max and insert functions of a priority queue are much less efficient.)</li></ul> <div class="mw-heading mw-heading2"><h2 id="Programming_language_implementations">Programming language implementations</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Heap_(data_structure)&amp;action=edit&amp;section=6" title="Edit section: Programming language implementations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>The <a href="/wiki/C%2B%2B_Standard_Library" title="C++ Standard Library">C++ Standard Library</a> provides the <style data-mw-deduplicate="TemplateStyles:r886049734">.mw-parser-output .monospaced{font-family:monospace,monospace}</style><span class="monospaced">make_heap</span>, <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">push_heap</span> and <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">pop_heap</span> algorithms for heaps (usually implemented as binary heaps), which operate on arbitrary random access <a href="/wiki/Iterator" title="Iterator">iterators</a>. It treats the iterators as a reference to an array, and uses the array-to-heap conversion. It also provides the container adaptor <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">priority_queue</span>, which wraps these facilities in a container-like class. However, there is no standard support for the replace, sift-up/sift-down, or decrease/increase-key operations.</li> <li>The <a href="/wiki/Boost_(C%2B%2B_libraries)" title="Boost (C++ libraries)">Boost C++ libraries</a> include a heaps library. Unlike the STL, it supports decrease and increase operations, and supports additional types of heap: specifically, it supports <i>d</i>-ary, binomial, Fibonacci, pairing and skew heaps.</li> <li>There is a <a rel="nofollow" class="external text" href="https://github.com/valyala/gheap">generic heap implementation</a> for <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> and <a href="/wiki/C%2B%2B" title="C++">C++</a> with <a href="/wiki/D-ary_heap" title="D-ary heap">D-ary heap</a> and <a href="/wiki/B-heap" title="B-heap">B-heap</a> support. It provides an STL-like API.</li> <li>The standard library of the <a href="/wiki/D_(programming_language)" title="D (programming language)">D programming language</a> includes <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_container_binaryheap.html"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">std.container.BinaryHeap</span></a>, which is implemented in terms of D's <a rel="nofollow" class="external text" href="https://tour.dlang.org/tour/en/basics/ranges">ranges</a>. Instances can be constructed from any <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_range_primitives.html#isRandomAccessRange">random-access range</a>. <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">BinaryHeap</span> exposes an <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_range_primitives.html#isInputRange">input range interface</a> that allows iteration with D's built-in <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">foreach</span> statements and integration with the range-based API of the <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_algorithm.html"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">std.algorithm</span> package</a>.</li> <li>For <a href="/wiki/Haskell" title="Haskell">Haskell</a> there is the <a rel="nofollow" class="external text" href="https://hackage.haskell.org/package/heaps"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">Data.Heap</span></a> module.</li> <li>The <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> platform (since version 1.5) provides a binary heap implementation with the class <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/PriorityQueue.html">java.util.PriorityQueue</a></code> in the <a href="/wiki/Java_Collections_Framework" class="mw-redirect" title="Java Collections Framework">Java Collections Framework</a>. This class implements by default a min-heap; to implement a max-heap, programmer should write a custom comparator. There is no support for the replace, sift-up/sift-down, or decrease/increase-key operations.</li> <li><a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a> has a <a rel="nofollow" class="external text" href="https://docs.python.org/library/heapq.html"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">heapq</span></a> module that implements a priority queue using a binary heap. The library exposes a heapreplace function to support k-way merging.</li> <li><a href="/wiki/PHP" title="PHP">PHP</a> has both max-heap (<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">SplMaxHeap</span>) and min-heap (<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">SplMinHeap</span>) as of version 5.3 in the Standard PHP Library.</li> <li><a href="/wiki/Perl" title="Perl">Perl</a> has implementations of binary, binomial, and Fibonacci heaps in the <a rel="nofollow" class="external text" href="https://metacpan.org/module/Heap"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">Heap</span></a> distribution available on <a href="/wiki/CPAN" title="CPAN">CPAN</a>.</li> <li>The <a href="/wiki/Go_(programming_language)" title="Go (programming language)">Go</a> language contains a <a rel="nofollow" class="external text" href="https://golang.org/pkg/container/heap/"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">heap</span></a> package with heap algorithms that operate on an arbitrary type that satisfies a given interface. That package does not support the replace, sift-up/sift-down, or decrease/increase-key operations.</li> <li>Apple's <a href="/wiki/Core_Foundation" title="Core Foundation">Core Foundation</a> library contains a <a rel="nofollow" class="external text" href="https://developer.apple.com/documentation/corefoundation/cfbinaryheap"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">CFBinaryHeap</span></a> structure.</li> <li><a href="/wiki/Pharo" title="Pharo">Pharo</a> has an implementation of a heap in the Collections-Sequenceable package along with a set of test cases. A heap is used in the implementation of the timer event loop.</li> <li>The <a href="/wiki/Rust_(programming_language)" title="Rust (programming language)">Rust</a> programming language has a binary max-heap implementation, <a rel="nofollow" class="external text" href="https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">BinaryHeap</span></a>, in the <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">collections</span> module of its standard library.</li> <li><a href="/wiki/.NET" title=".NET">.NET</a> has <a rel="nofollow" class="external text" href="https://docs.microsoft.com/dotnet/api/system.collections.generic.priorityqueue-2">PriorityQueue</a> class which uses quaternary (d-ary) min-heap implementation. It is available from .NET 6.</li></ul> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Heap_(data_structure)&amp;action=edit&amp;section=7" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a href="/wiki/Sorting_algorithm" title="Sorting algorithm">Sorting algorithm</a></li> <li><a href="/wiki/Search_data_structure" title="Search data structure">Search data structure</a></li> <li><a href="/wiki/Stack_(abstract_data_type)" title="Stack (abstract data type)">Stack (abstract data type)</a></li> <li><a href="/wiki/Queue_(abstract_data_type)" title="Queue (abstract data type)">Queue (abstract data type)</a></li> <li><a href="/wiki/Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">Tree (data structure)</a></li> <li><a href="/wiki/Treap" title="Treap">Treap</a>, a form of binary search tree based on heap-ordered trees</li></ul> <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=Heap_(data_structure)&amp;action=edit&amp;section=8" 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 mw-references-columns"><ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">Black (ed.), Paul E. (2004-12-14). Entry for <i>heap</i> in <i><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></i>. Online version. U.S. <a href="/wiki/National_Institute_of_Standards_and_Technology" title="National Institute of Standards and Technology">National Institute of Standards and Technology</a>, 14 December 2004. Retrieved on 2017-10-08 from <a rel="nofollow" class="external free" href="https://xlinux.nist.gov/dads/HTML/heap.html">https://xlinux.nist.gov/dads/HTML/heap.html</a>.</span> </li> <li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</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="CITEREFCORMEN2009" class="citation book cs1">CORMEN, THOMAS H. (2009). <i>INTRODUCTION TO ALGORITHMS</i>. United States of America: The MIT Press Cambridge, Massachusetts London, England. pp.&#160;151–152. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-262-03384-8" title="Special:BookSources/978-0-262-03384-8"><bdi>978-0-262-03384-8</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=INTRODUCTION+TO+ALGORITHMS&amp;rft.place=United+States+of+America&amp;rft.pages=151-152&amp;rft.pub=The+MIT+Press+Cambridge%2C+Massachusetts+London%2C+England&amp;rft.date=2009&amp;rft.isbn=978-0-262-03384-8&amp;rft.aulast=CORMEN&amp;rft.aufirst=THOMAS+H.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" 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="CITEREFWilliams1964" class="citation cs2"><a href="/wiki/J._W._J._Williams" title="J. W. J. Williams">Williams, J. W. J.</a> (1964), "Algorithm 232 - Heapsort", <i><a href="/wiki/Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a></i>, <b>7</b> (6): 347–348, <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%2F512274.512284">10.1145/512274.512284</a></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Communications+of+the+ACM&amp;rft.atitle=Algorithm+232+-+Heapsort&amp;rft.volume=7&amp;rft.issue=6&amp;rft.pages=347-348&amp;rft.date=1964&amp;rft_id=info%3Adoi%2F10.1145%2F512274.512284&amp;rft.aulast=Williams&amp;rft.aufirst=J.+W.+J.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" 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">The Python Standard Library, 8.4. heapq — Heap queue algorithm, <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/heapq.html#heapq.heappush">heapq.heappush</a></span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">The Python Standard Library, 8.4. heapq — Heap queue algorithm, <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/heapq.html#heapq.heappop">heapq.heappop</a></span> </li> <li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text">The Python Standard Library, 8.4. heapq — Heap queue algorithm, <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/heapq.html#heapq.heapreplace">heapq.heapreplace</a></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="CITEREFSuchenek2012" class="citation cs2">Suchenek, Marek A. (2012), "Elementary Yet Precise Worst-Case Analysis of Floyd's Heap-Construction Program", <i>Fundamenta Informaticae</i>, <b>120</b> (1), IOS Press: 75–92, <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.3233%2FFI-2012-751">10.3233/FI-2012-751</a></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Fundamenta+Informaticae&amp;rft.atitle=Elementary+Yet+Precise+Worst-Case+Analysis+of+Floyd%27s+Heap-Construction+Program&amp;rft.volume=120&amp;rft.issue=1&amp;rft.pages=75-92&amp;rft.date=2012&amp;rft_id=info%3Adoi%2F10.3233%2FFI-2012-751&amp;rft.aulast=Suchenek&amp;rft.aufirst=Marek+A.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span>.</span> </li> <li id="cite_note-CLRS-9"><span class="mw-cite-backlink">^ <a href="#cite_ref-CLRS_9-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-CLRS_9-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-CLRS_9-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-CLRS_9-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFCormenLeisersonRivest1990" 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/Ron_Rivest" title="Ron Rivest">Rivest, Ronald L.</a> (1990). <a href="/wiki/Introduction_to_Algorithms" title="Introduction to Algorithms"><i>Introduction to Algorithms</i></a> (1st&#160;ed.). MIT Press and McGraw-Hill. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/0-262-03141-8" title="Special:BookSources/0-262-03141-8"><bdi>0-262-03141-8</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Introduction+to+Algorithms&amp;rft.edition=1st&amp;rft.pub=MIT+Press+and+McGraw-Hill&amp;rft.date=1990&amp;rft.isbn=0-262-03141-8&amp;rft.aulast=Cormen&amp;rft.aufirst=Thomas+H.&amp;rft.au=Leiserson%2C+Charles+E.&amp;rft.au=Rivest%2C+Ronald+L.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-sleator-tarjan-skew-10"><span class="mw-cite-backlink">^ <a href="#cite_ref-sleator-tarjan-skew_10-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-sleator-tarjan-skew_10-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-sleator-tarjan-skew_10-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="CITEREFSleatorTarjan1986" class="citation journal cs1"><a href="/wiki/Daniel_Sleator" title="Daniel Sleator">Sleator, Daniel Dominic</a>; <a href="/wiki/Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert Endre</a> (February 1986). <a rel="nofollow" class="external text" href="https://www.cs.cmu.edu/~sleator/papers/Adjusting-Heaps.htm">"Self-Adjusting Heaps"</a>. <i><a href="/wiki/SIAM_Journal_on_Computing" title="SIAM Journal on Computing">SIAM Journal on Computing</a></i>. <b>15</b> (1): 52–69. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.93.6678">10.1.1.93.6678</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2F0215004">10.1137/0215004</a>. <a href="/wiki/ISSN_(identifier)" class="mw-redirect" title="ISSN (identifier)">ISSN</a>&#160;<a rel="nofollow" class="external text" href="https://search.worldcat.org/issn/0097-5397">0097-5397</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=SIAM+Journal+on+Computing&amp;rft.atitle=Self-Adjusting+Heaps&amp;rft.volume=15&amp;rft.issue=1&amp;rft.pages=52-69&amp;rft.date=1986-02&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.93.6678%23id-name%3DCiteSeerX&amp;rft.issn=0097-5397&amp;rft_id=info%3Adoi%2F10.1137%2F0215004&amp;rft.aulast=Sleator&amp;rft.aufirst=Daniel+Dominic&amp;rft.au=Tarjan%2C+Robert+Endre&amp;rft_id=https%3A%2F%2Fwww.cs.cmu.edu%2F~sleator%2Fpapers%2FAdjusting-Heaps.htm&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-tarjan-leftist-11"><span class="mw-cite-backlink">^ <a href="#cite_ref-tarjan-leftist_11-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-tarjan-leftist_11-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 id="CITEREFTarjan1983" class="citation book cs1"><a href="/wiki/Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert</a> (1983). "3.3. Leftist heaps". <i>Data Structures and Network Algorithms</i>. pp.&#160;38–42. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2F1.9781611970265">10.1137/1.9781611970265</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-89871-187-5" title="Special:BookSources/978-0-89871-187-5"><bdi>978-0-89871-187-5</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=3.3.+Leftist+heaps&amp;rft.btitle=Data+Structures+and+Network+Algorithms&amp;rft.pages=38-42&amp;rft.date=1983&amp;rft_id=info%3Adoi%2F10.1137%2F1.9781611970265&amp;rft.isbn=978-0-89871-187-5&amp;rft.aulast=Tarjan&amp;rft.aufirst=Robert&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-hayward-mcdiarmid-heap-build-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-hayward-mcdiarmid-heap-build_12-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHaywardMcDiarmid1991" class="citation journal cs1">Hayward, Ryan; McDiarmid, Colin (1991). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160205023201/http://www.stats.ox.ac.uk/__data/assets/pdf_file/0015/4173/heapbuildjalg.pdf">"Average Case Analysis of Heap Building by Repeated Insertion"</a> <span class="cs1-format">(PDF)</span>. <i>J. Algorithms</i>. <b>12</b>: 126–153. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.353.7888">10.1.1.353.7888</a></span>. <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%2F0196-6774%2891%2990027-v">10.1016/0196-6774(91)90027-v</a>. Archived from <a rel="nofollow" class="external text" href="http://www.stats.ox.ac.uk/__data/assets/pdf_file/0015/4173/heapbuildjalg.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2016-02-05<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-01-28</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=J.+Algorithms&amp;rft.atitle=Average+Case+Analysis+of+Heap+Building+by+Repeated+Insertion&amp;rft.volume=12&amp;rft.pages=126-153&amp;rft.date=1991&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.353.7888%23id-name%3DCiteSeerX&amp;rft_id=info%3Adoi%2F10.1016%2F0196-6774%2891%2990027-v&amp;rft.aulast=Hayward&amp;rft.aufirst=Ryan&amp;rft.au=McDiarmid%2C+Colin&amp;rft_id=http%3A%2F%2Fwww.stats.ox.ac.uk%2F&#95;_data%2Fassets%2Fpdf_file%2F0015%2F4173%2Fheapbuildjalg.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></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://brilliant.org/wiki/binomial-heap/">"Binomial Heap | Brilliant Math &amp; Science Wiki"</a>. <i>brilliant.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-09-30</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=brilliant.org&amp;rft.atitle=Binomial+Heap+%7C+Brilliant+Math+%26+Science+Wiki&amp;rft_id=https%3A%2F%2Fbrilliant.org%2Fwiki%2Fbinomial-heap%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-brodal-okasaki-16"><span class="mw-cite-backlink">^ <a href="#cite_ref-brodal-okasaki_16-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-brodal-okasaki_16-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 id="CITEREFBrodalOkasaki1996" class="citation cs2">Brodal, Gerth Stølting; Okasaki, Chris (November 1996), "Optimal purely functional priority queues", <i>Journal of Functional Programming</i>, <b>6</b> (6): 839–857, <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.1017%2Fs095679680000201x">10.1017/s095679680000201x</a></span></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Journal+of+Functional+Programming&amp;rft.atitle=Optimal+purely+functional+priority+queues&amp;rft.volume=6&amp;rft.issue=6&amp;rft.pages=839-857&amp;rft.date=1996-11&amp;rft_id=info%3Adoi%2F10.1017%2Fs095679680000201x&amp;rft.aulast=Brodal&amp;rft.aufirst=Gerth+St%C3%B8lting&amp;rft.au=Okasaki%2C+Chris&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFOkasaki1998" class="citation book cs1"><a href="/wiki/Chris_Okasaki" title="Chris Okasaki">Okasaki, Chris</a> (1998). "10.2. Structural Abstraction". <i>Purely Functional Data Structures</i> (1st&#160;ed.). pp.&#160;158–162. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/9780521631242" title="Special:BookSources/9780521631242"><bdi>9780521631242</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=10.2.+Structural+Abstraction&amp;rft.btitle=Purely+Functional+Data+Structures&amp;rft.pages=158-162&amp;rft.edition=1st&amp;rft.date=1998&amp;rft.isbn=9780521631242&amp;rft.aulast=Okasaki&amp;rft.aufirst=Chris&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFTakaoka1999" class="citation cs2"><a href="/w/index.php?title=Tadao_Takaoka&amp;action=edit&amp;redlink=1" class="new" title="Tadao Takaoka (page does not exist)">Takaoka, Tadao</a> (1999), <a rel="nofollow" class="external text" href="https://ir.canterbury.ac.nz/bitstream/handle/10092/14769/2-3heaps.pdf"><i>Theory of 2–3 Heaps</i></a> <span class="cs1-format">(PDF)</span>, p.&#160;12</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Theory+of+2%E2%80%933+Heaps&amp;rft.pages=12&amp;rft.date=1999&amp;rft.aulast=Takaoka&amp;rft.aufirst=Tadao&amp;rft_id=https%3A%2F%2Fir.canterbury.ac.nz%2Fbitstream%2Fhandle%2F10092%2F14769%2F2-3heaps.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-Iacono-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-Iacono_19-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFIacono2000" class="citation cs2"><a href="/wiki/John_Iacono" title="John Iacono">Iacono, John</a> (2000), "Improved upper bounds for pairing heaps", <a rel="nofollow" class="external text" href="http://john2.poly.edu/papers/swat00/paper.pdf"><i>Proc. 7th Scandinavian Workshop on Algorithm Theory</i></a> <span class="cs1-format">(PDF)</span>, Lecture Notes in Computer Science, vol.&#160;1851, Springer-Verlag, pp.&#160;63–77, <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1110.4428">1110.4428</a></span>, <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.748.7812">10.1.1.748.7812</a></span>, <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F3-540-44985-X_5">10.1007/3-540-44985-X_5</a>, <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/3-540-67690-2" title="Special:BookSources/3-540-67690-2"><bdi>3-540-67690-2</bdi></a></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Improved+upper+bounds+for+pairing+heaps&amp;rft.btitle=Proc.+7th+Scandinavian+Workshop+on+Algorithm+Theory&amp;rft.series=Lecture+Notes+in+Computer+Science&amp;rft.pages=63-77&amp;rft.pub=Springer-Verlag&amp;rft.date=2000&amp;rft_id=info%3Aarxiv%2F1110.4428&amp;rft_id=info%3Adoi%2F10.1007%2F3-540-44985-X_5&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.748.7812%23id-name%3DCiteSeerX&amp;rft.isbn=3-540-67690-2&amp;rft.aulast=Iacono&amp;rft.aufirst=John&amp;rft_id=http%3A%2F%2Fjohn2.poly.edu%2Fpapers%2Fswat00%2Fpaper.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-Fredman1999-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-Fredman1999_20-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFFredman1999" class="citation journal cs1"><a href="/wiki/Michael_Fredman" title="Michael Fredman">Fredman, Michael Lawrence</a> (July 1999). <a rel="nofollow" class="external text" href="http://www.uqac.ca/azinflou/Fichiers840/EfficiencyPairingHeap.pdf">"On the Efficiency of Pairing Heaps and Related Data Structures"</a> <span class="cs1-format">(PDF)</span>. <i><a href="/wiki/Journal_of_the_Association_for_Computing_Machinery" class="mw-redirect" title="Journal of the Association for Computing Machinery">Journal of the Association for Computing Machinery</a></i>. <b>46</b> (4): 473–501. <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%2F320211.320214">10.1145/320211.320214</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Journal+of+the+Association+for+Computing+Machinery&amp;rft.atitle=On+the+Efficiency+of+Pairing+Heaps+and+Related+Data+Structures&amp;rft.volume=46&amp;rft.issue=4&amp;rft.pages=473-501&amp;rft.date=1999-07&amp;rft_id=info%3Adoi%2F10.1145%2F320211.320214&amp;rft.aulast=Fredman&amp;rft.aufirst=Michael+Lawrence&amp;rft_id=http%3A%2F%2Fwww.uqac.ca%2Fazinflou%2FFichiers840%2FEfficiencyPairingHeap.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFPettie2005" class="citation conference cs1">Pettie, Seth (2005). <a rel="nofollow" class="external text" href="http://web.eecs.umich.edu/~pettie/papers/focs05.pdf"><i>Towards a Final Analysis of Pairing Heaps</i></a> <span class="cs1-format">(PDF)</span>. FOCS '05 Proceedings of the 46th Annual IEEE Symposium on Foundations of Computer Science. pp.&#160;174–183. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.549.471">10.1.1.549.471</a></span>. <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%2FSFCS.2005.75">10.1109/SFCS.2005.75</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/0-7695-2468-0" title="Special:BookSources/0-7695-2468-0"><bdi>0-7695-2468-0</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=conference&amp;rft.btitle=Towards+a+Final+Analysis+of+Pairing+Heaps&amp;rft.pages=174-183&amp;rft.date=2005&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.549.471%23id-name%3DCiteSeerX&amp;rft_id=info%3Adoi%2F10.1109%2FSFCS.2005.75&amp;rft.isbn=0-7695-2468-0&amp;rft.aulast=Pettie&amp;rft.aufirst=Seth&amp;rft_id=http%3A%2F%2Fweb.eecs.umich.edu%2F~pettie%2Fpapers%2Ffocs05.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHaeuplerSenTarjan2011" class="citation journal cs1">Haeupler, Bernhard; Sen, Siddhartha; <a href="/wiki/Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (November 2011). <a rel="nofollow" class="external text" href="http://sidsen.org/papers/rp-heaps-journal.pdf">"Rank-pairing heaps"</a> <span class="cs1-format">(PDF)</span>. <i>SIAM J. Computing</i>. <b>40</b> (6): 1463–1485. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2F100785351">10.1137/100785351</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=SIAM+J.+Computing&amp;rft.atitle=Rank-pairing+heaps&amp;rft.volume=40&amp;rft.issue=6&amp;rft.pages=1463-1485&amp;rft.date=2011-11&amp;rft_id=info%3Adoi%2F10.1137%2F100785351&amp;rft.aulast=Haeupler&amp;rft.aufirst=Bernhard&amp;rft.au=Sen%2C+Siddhartha&amp;rft.au=Tarjan%2C+Robert+E.&amp;rft_id=http%3A%2F%2Fsidsen.org%2Fpapers%2Frp-heaps-journal.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-Fredman_And_Tarjan-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-Fredman_And_Tarjan_24-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFFredmanTarjan1987" class="citation journal cs1"><a href="/wiki/Michael_Fredman" title="Michael Fredman">Fredman, Michael Lawrence</a>; <a href="/wiki/Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (July 1987). <a rel="nofollow" class="external text" href="http://bioinfo.ict.ac.cn/~dbu/AlgorithmCourses/Lectures/Fibonacci-Heap-Tarjan.pdf">"Fibonacci heaps and their uses in improved network optimization algorithms"</a> <span class="cs1-format">(PDF)</span>. <i><a href="/wiki/Journal_of_the_Association_for_Computing_Machinery" class="mw-redirect" title="Journal of the Association for Computing Machinery">Journal of the Association for Computing Machinery</a></i>. <b>34</b> (3): 596–615. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.309.8927">10.1.1.309.8927</a></span>. <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%2F28869.28874">10.1145/28869.28874</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Journal+of+the+Association+for+Computing+Machinery&amp;rft.atitle=Fibonacci+heaps+and+their+uses+in+improved+network+optimization+algorithms&amp;rft.volume=34&amp;rft.issue=3&amp;rft.pages=596-615&amp;rft.date=1987-07&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.309.8927%23id-name%3DCiteSeerX&amp;rft_id=info%3Adoi%2F10.1145%2F28869.28874&amp;rft.aulast=Fredman&amp;rft.aufirst=Michael+Lawrence&amp;rft.au=Tarjan%2C+Robert+E.&amp;rft_id=http%3A%2F%2Fbioinfo.ict.ac.cn%2F~dbu%2FAlgorithmCourses%2FLectures%2FFibonacci-Heap-Tarjan.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFBrodalLagogiannisTarjan2012" class="citation conference cs1"><a href="/wiki/Gerth_St%C3%B8lting_Brodal" class="mw-redirect" title="Gerth Stølting Brodal">Brodal, Gerth Stølting</a>; Lagogiannis, George; <a href="/wiki/Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (2012). <a rel="nofollow" class="external text" href="http://www.cs.au.dk/~gerth/papers/stoc12.pdf"><i>Strict Fibonacci heaps</i></a> <span class="cs1-format">(PDF)</span>. Proceedings of the 44th symposium on Theory of Computing - STOC '12. pp.&#160;1177–1184. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&#160;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.233.1740">10.1.1.233.1740</a></span>. <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%2F2213977.2214082">10.1145/2213977.2214082</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-1-4503-1245-5" title="Special:BookSources/978-1-4503-1245-5"><bdi>978-1-4503-1245-5</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=conference&amp;rft.btitle=Strict+Fibonacci+heaps&amp;rft.pages=1177-1184&amp;rft.date=2012&amp;rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.233.1740%23id-name%3DCiteSeerX&amp;rft_id=info%3Adoi%2F10.1145%2F2213977.2214082&amp;rft.isbn=978-1-4503-1245-5&amp;rft.aulast=Brodal&amp;rft.aufirst=Gerth+St%C3%B8lting&amp;rft.au=Lagogiannis%2C+George&amp;rft.au=Tarjan%2C+Robert+E.&amp;rft_id=http%3A%2F%2Fwww.cs.au.dk%2F~gerth%2Fpapers%2Fstoc12.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFBrodal1996" class="citation cs2"><a href="/wiki/Gerth_St%C3%B8lting_Brodal" class="mw-redirect" title="Gerth Stølting Brodal">Brodal, Gerth S.</a> (1996), <a rel="nofollow" class="external text" href="http://www.cs.au.dk/~gerth/papers/soda96.pdf">"Worst-Case Efficient Priority Queues"</a> <span class="cs1-format">(PDF)</span>, <i>Proc. 7th Annual ACM-SIAM Symposium on Discrete Algorithms</i>, pp.&#160;52–58</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Worst-Case+Efficient+Priority+Queues&amp;rft.btitle=Proc.+7th+Annual+ACM-SIAM+Symposium+on+Discrete+Algorithms&amp;rft.pages=52-58&amp;rft.date=1996&amp;rft.aulast=Brodal&amp;rft.aufirst=Gerth+S.&amp;rft_id=http%3A%2F%2Fwww.cs.au.dk%2F~gerth%2Fpapers%2Fsoda96.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFGoodrichTamassia2004" class="citation book cs1"><a href="/wiki/Michael_T._Goodrich" title="Michael T. Goodrich">Goodrich, Michael T.</a>; <a href="/wiki/Roberto_Tamassia" title="Roberto Tamassia">Tamassia, Roberto</a> (2004). "7.3.6. Bottom-Up Heap Construction". <i>Data Structures and Algorithms in Java</i> (3rd&#160;ed.). pp.&#160;338–341. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/0-471-46983-1" title="Special:BookSources/0-471-46983-1"><bdi>0-471-46983-1</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=7.3.6.+Bottom-Up+Heap+Construction&amp;rft.btitle=Data+Structures+and+Algorithms+in+Java&amp;rft.pages=338-341&amp;rft.edition=3rd&amp;rft.date=2004&amp;rft.isbn=0-471-46983-1&amp;rft.aulast=Goodrich&amp;rft.aufirst=Michael+T.&amp;rft.au=Tamassia%2C+Roberto&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> <li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFFrederickson1993" class="citation cs2">Frederickson, Greg N. (1993), "An Optimal Algorithm for Selection in a Min-Heap", <a rel="nofollow" class="external text" href="https://web.archive.org/web/20121203045606/http://ftp.cs.purdue.edu/research/technical_reports/1991/TR%2091-027.pdf"><i>Information and Computation</i></a> <span class="cs1-format">(PDF)</span>, vol.&#160;104, Academic Press, pp.&#160;197–214, <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.1006%2Finco.1993.1030">10.1006/inco.1993.1030</a></span>, archived from <a rel="nofollow" class="external text" href="http://ftp.cs.purdue.edu/research/technical_reports/1991/TR%2091-027.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2012-12-03<span class="reference-accessdate">, retrieved <span class="nowrap">2010-10-31</span></span></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=An+Optimal+Algorithm+for+Selection+in+a+Min-Heap&amp;rft.btitle=Information+and+Computation&amp;rft.pages=197-214&amp;rft.pub=Academic+Press&amp;rft.date=1993&amp;rft_id=info%3Adoi%2F10.1006%2Finco.1993.1030&amp;rft.aulast=Frederickson&amp;rft.aufirst=Greg+N.&amp;rft_id=http%3A%2F%2Fftp.cs.purdue.edu%2Fresearch%2Ftechnical_reports%2F1991%2FTR%252091-027.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></span> </li> </ol></div></div> <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=Heap_(data_structure)&amp;action=edit&amp;section=9" 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"><span><img alt="" src="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/30px-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/45px-Commons-logo.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/59px-Commons-logo.svg.png 2x" data-file-width="1024" data-file-height="1376" /></span></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:Heap_data_structures" class="extiw" title="commons:Category:Heap data structures">Heap data structures</a></span>.</div></div> </div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1235681985"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1237033735"><div class="side-box side-box-right plainlinks sistersitebox"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1126788409"> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/60px-Wikibooks-logo-en-noslogan.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/80px-Wikibooks-logo-en-noslogan.svg.png 2x" data-file-width="400" data-file-height="400" /></span></span></div> <div class="side-box-text plainlist">The Wikibook <i><a href="https://en.wikibooks.org/wiki/Data_Structures" class="extiw" title="wikibooks:Data Structures">Data Structures</a></i> has a page on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Data_Structures/Min_and_Max_Heaps" class="extiw" title="wikibooks:Data Structures/Min and Max Heaps">Min and Max Heaps</a></b></i></div></div> </div> <ul><li><a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/Heap.html">Heap</a> at Wolfram MathWorld</li> <li><a rel="nofollow" class="external text" href="https://www.cs.auckland.ac.nz/software/AlgAnim/heaps.html">Explanation</a> of how the basic heap algorithms work</li> <li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFBentley2000" class="citation book cs1">Bentley, Jon Louis (2000). <i>Programming Pearls</i> (2nd&#160;ed.). Addison Wesley. pp.&#160;147–162. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/0201657880" title="Special:BookSources/0201657880"><bdi>0201657880</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Programming+Pearls&amp;rft.pages=147-162&amp;rft.edition=2nd&amp;rft.pub=Addison+Wesley&amp;rft.date=2000&amp;rft.isbn=0201657880&amp;rft.aulast=Bentley&amp;rft.aufirst=Jon+Louis&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AHeap+%28data+structure%29" class="Z3988"></span></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="Tree_data_structures" style="padding:3px"><table class="nowraplinks 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:CS_trees" title="Template:CS trees"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:CS_trees" title="Template talk:CS trees"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:CS_trees" title="Special:EditPage/Template:CS trees"><abbr title="Edit this template">e</abbr></a></li></ul></div><div id="Tree_data_structures" style="font-size:114%;margin:0 4em"><a href="/wiki/Tree_(abstract_data_type)" title="Tree (abstract data type)">Tree data structures</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Search_tree" title="Search tree">Search trees</a><br />(<a href="/wiki/Set_(abstract_data_type)" title="Set (abstract data type)">dynamic sets</a>/<a href="/wiki/Associative_array" title="Associative array">associative arrays</a>)</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/2%E2%80%933_tree" title="2–3 tree">2–3</a></li> <li><a href="/wiki/2%E2%80%933%E2%80%934_tree" title="2–3–4 tree">2–3–4</a></li> <li><a href="/wiki/AA_tree" title="AA tree">AA</a></li> <li><a href="/wiki/(a,b)-tree" class="mw-redirect" title="(a,b)-tree">(a,b)</a></li> <li><a href="/wiki/AVL_tree" title="AVL tree">AVL</a></li> <li><a href="/wiki/B-tree" title="B-tree">B</a></li> <li><a href="/wiki/B%2B_tree" title="B+ tree">B+</a></li> <li><a href="/wiki/B*-tree" class="mw-redirect" title="B*-tree">B*</a></li> <li><a href="/wiki/Bx-tree" title="Bx-tree">B<sup>x</sup></a></li> <li>(<a href="/wiki/Optimal_binary_search_tree" title="Optimal binary search tree">Optimal</a>)&#160;<a href="/wiki/Binary_search_tree" title="Binary search tree">Binary search</a></li> <li><a href="/wiki/Dancing_tree" title="Dancing tree">Dancing</a></li> <li><a href="/wiki/HTree" title="HTree">HTree</a></li> <li><a href="/wiki/Interval_tree" title="Interval tree">Interval</a></li> <li><a href="/wiki/Order_statistic_tree" title="Order statistic tree">Order statistic</a></li> <li><a href="/wiki/Palindrome_tree" title="Palindrome tree">Palindrome</a></li> <li>(<a href="/wiki/Left-leaning_red%E2%80%93black_tree" title="Left-leaning red–black tree">Left-leaning</a>)&#160;<a href="/wiki/Red%E2%80%93black_tree" title="Red–black tree">Red–black</a></li> <li><a href="/wiki/Scapegoat_tree" title="Scapegoat tree">Scapegoat</a></li> <li><a href="/wiki/Splay_tree" title="Splay tree">Splay</a></li> <li><a href="/wiki/T-tree" title="T-tree">T</a></li> <li><a href="/wiki/Treap" title="Treap">Treap</a></li> <li><a href="/wiki/UB-tree" title="UB-tree">UB</a></li> <li><a href="/wiki/Weight-balanced_tree" title="Weight-balanced tree">Weight-balanced</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a class="mw-selflink selflink">Heaps</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Binary_heap" title="Binary heap">Binary</a></li> <li><a href="/wiki/Binomial_heap" title="Binomial heap">Binomial</a></li> <li><a href="/wiki/Brodal_queue" title="Brodal queue">Brodal</a></li> <li><a href="/wiki/D-ary_heap" title="D-ary heap"><i>d</i>-ary</a></li> <li><a href="/wiki/Fibonacci_heap" title="Fibonacci heap">Fibonacci</a></li> <li><a href="/wiki/Leftist_tree" title="Leftist tree">Leftist</a></li> <li><a href="/wiki/Pairing_heap" title="Pairing heap">Pairing</a></li> <li><a href="/wiki/Skew_binomial_heap" title="Skew binomial heap">Skew binomial</a></li> <li><a href="/wiki/Skew_heap" title="Skew heap">Skew</a></li> <li><a href="/wiki/Van_Emde_Boas_tree" title="Van Emde Boas tree">van Emde Boas</a></li> <li><a href="/wiki/Weak_heap" title="Weak heap">Weak</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Trie" title="Trie">Tries</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Ctrie" title="Ctrie">Ctrie</a></li> <li><a href="/wiki/C-trie" title="C-trie">C-trie (compressed ADT)</a></li> <li><a href="/wiki/Hash_tree_(persistent_data_structure)" title="Hash tree (persistent data structure)">Hash</a></li> <li><a href="/wiki/Radix_tree" title="Radix tree">Radix</a></li> <li><a href="/wiki/Suffix_tree" title="Suffix tree">Suffix</a></li> <li><a href="/wiki/Ternary_search_tree" title="Ternary search tree">Ternary search</a></li> <li><a href="/wiki/X-fast_trie" title="X-fast trie">X-fast</a></li> <li><a href="/wiki/Y-fast_trie" title="Y-fast trie">Y-fast</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Spatial_index" class="mw-redirect" title="Spatial index">Spatial</a> data partitioning trees</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Ball_tree" title="Ball tree">Ball</a></li> <li><a href="/wiki/BK-tree" title="BK-tree">BK</a></li> <li><a href="/wiki/BSP_tree" class="mw-redirect" title="BSP tree">BSP</a></li> <li><a href="/wiki/Cartesian_tree" title="Cartesian tree">Cartesian</a></li> <li><a href="/wiki/Hilbert_R-tree" title="Hilbert R-tree">Hilbert R</a></li> <li><a href="/wiki/K-d_tree" title="K-d tree"><i>k</i>-d</a> (<a href="/wiki/Implicit_k-d_tree" title="Implicit k-d tree">implicit <i>k</i>-d</a>)</li> <li><a href="/wiki/M-tree" title="M-tree">M</a></li> <li><a href="/wiki/Metric_tree" title="Metric tree">Metric</a></li> <li><a href="/wiki/MVP_tree" class="mw-redirect" title="MVP tree">MVP</a></li> <li><a href="/wiki/Octree" title="Octree">Octree</a></li> <li><a href="/wiki/PH-tree" title="PH-tree">PH</a></li> <li><a href="/wiki/Priority_R-tree" title="Priority R-tree">Priority R</a></li> <li><a href="/wiki/Quadtree" title="Quadtree">Quad</a></li> <li><a href="/wiki/R-tree" title="R-tree">R</a></li> <li><a href="/wiki/R%2B_tree" title="R+ tree">R+</a></li> <li><a href="/wiki/R*_tree" class="mw-redirect" title="R* tree">R*</a></li> <li><a href="/wiki/Segment_tree" title="Segment tree">Segment</a></li> <li><a href="/wiki/Vantage-point_tree" title="Vantage-point tree">VP</a></li> <li><a href="/wiki/X-tree" title="X-tree">X</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other trees</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Cover_tree" title="Cover tree">Cover</a></li> <li><a href="/wiki/Exponential_tree" title="Exponential tree">Exponential</a></li> <li><a href="/wiki/Fenwick_tree" title="Fenwick tree">Fenwick</a></li> <li><a href="/wiki/Finger_tree" title="Finger tree">Finger</a></li> <li><a href="/wiki/Fractal_tree_index" title="Fractal tree index">Fractal tree index</a></li> <li><a href="/wiki/Fusion_tree" title="Fusion tree">Fusion</a></li> <li><a href="/wiki/Hash_calendar" title="Hash calendar">Hash calendar</a></li> <li><a href="/wiki/IDistance" title="IDistance">iDistance</a></li> <li><a href="/wiki/K-ary_tree" class="mw-redirect" title="K-ary tree">K-ary</a></li> <li><a href="/wiki/Left-child_right-sibling_binary_tree" title="Left-child right-sibling binary tree">Left-child right-sibling</a></li> <li><a href="/wiki/Link/cut_tree" title="Link/cut tree">Link/cut</a></li> <li><a href="/wiki/Log-structured_merge-tree" title="Log-structured merge-tree">Log-structured merge</a></li> <li><a href="/wiki/Merkle_tree" title="Merkle tree">Merkle</a></li> <li><a href="/wiki/PQ_tree" title="PQ tree">PQ</a></li> <li><a href="/wiki/Range_tree" title="Range tree">Range</a></li> <li><a href="/wiki/SPQR_tree" title="SPQR tree">SPQR</a></li> <li><a href="/wiki/Top_tree" title="Top tree">Top</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" aria-labelledby="Data_structures" 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"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1239400231"><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_structures" 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 href="/wiki/Linked_list" title="Linked list">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 class="mw-selflink selflink">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> <!-- NewPP limit report Parsed by mw‐api‐int.codfw.main‐5f67bcf949‐vdr7x Cached time: 20241127001055 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.742 seconds Real time usage: 0.921 seconds Preprocessor visited node count: 3301/1000000 Post‐expand include size: 89538/2097152 bytes Template argument size: 5120/2097152 bytes Highest expansion depth: 13/100 Expensive parser function count: 2/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 110322/5000000 bytes Lua time usage: 0.430/10.000 seconds Lua memory usage: 5359937/52428800 bytes Number of Wikibase entities loaded: 1/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 744.913 1 -total 39.26% 292.466 2 Template:Reflist 17.98% 133.955 6 Template:Cite_book 17.90% 133.315 1 Template:CS-Trees 17.79% 132.547 2 Template:Navbox 12.39% 92.325 1 Template:Short_description 10.31% 76.797 1 Template:Heap_Running_Times 8.94% 66.620 2 Template:Sister_project 8.57% 63.853 2 Template:Side_box 8.54% 63.642 1 Template:Commons_category --> <!-- Saved in parser cache with key enwiki:pcache:13996:|#|:idhash:canonical and timestamp 20241127001055 and revision id 1259776930. Rendering was triggered because: api-parse --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" 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=Heap_(data_structure)&amp;oldid=1259776930">https://en.wikipedia.org/w/index.php?title=Heap_(data_structure)&amp;oldid=1259776930</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:Heaps_(data_structures)" title="Category:Heaps (data structures)">Heaps (data structures)</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: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:Commons_category_link_is_on_Wikidata" title="Category:Commons category link is on Wikidata">Commons category link is on Wikidata</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 27 November 2024, at 00:10<span class="anonymous-show">&#160;(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=Heap_(data_structure)&amp;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"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></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"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-5cd4cd96d5-b96xc","wgBackendResponseTime":160,"wgPageParseReport":{"limitreport":{"cputime":"0.742","walltime":"0.921","ppvisitednodes":{"value":3301,"limit":1000000},"postexpandincludesize":{"value":89538,"limit":2097152},"templateargumentsize":{"value":5120,"limit":2097152},"expansiondepth":{"value":13,"limit":100},"expensivefunctioncount":{"value":2,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":110322,"limit":5000000},"entityaccesscount":{"value":1,"limit":400},"timingprofile":["100.00% 744.913 1 -total"," 39.26% 292.466 2 Template:Reflist"," 17.98% 133.955 6 Template:Cite_book"," 17.90% 133.315 1 Template:CS-Trees"," 17.79% 132.547 2 Template:Navbox"," 12.39% 92.325 1 Template:Short_description"," 10.31% 76.797 1 Template:Heap_Running_Times"," 8.94% 66.620 2 Template:Sister_project"," 8.57% 63.853 2 Template:Side_box"," 8.54% 63.642 1 Template:Commons_category"]},"scribunto":{"limitreport-timeusage":{"value":"0.430","limit":"10.000"},"limitreport-memusage":{"value":5359937,"limit":52428800}},"cachereport":{"origin":"mw-api-int.codfw.main-5f67bcf949-vdr7x","timestamp":"20241127001055","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Heap (data structure)","url":"https:\/\/en.wikipedia.org\/wiki\/Heap_(data_structure)","sameAs":"http:\/\/www.wikidata.org\/entity\/Q274089","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q274089","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-10-25T19:11:53Z","dateModified":"2024-11-27T00:10:49Z","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/c\/c4\/Max-Heap-new.svg","headline":"tree-based data structure in computer science"}</script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10