s c h e m a t i c s : c o o k b o o k

/ DataStructures? / Cookbook.FunctionalHeap

This Web


WebHome 
WebChanges 
TOC (with recipes)
NewRecipe 
WebTopicList 
WebStatistics 

Other Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Schematics


Schematics Home
Sourceforge Page
SchemeWiki.org
Original Cookbook
RSS

Scheme Links


Schemers.org
Scheme FAQ
R5RS
SRFIs
Scheme Cross Reference
PLT Scheme SISC
Scheme48 SCM
MIT Scheme scsh
JScheme Kawa
Chicken Guile
Bigloo Tiny
Gambit LispMe
GaucheChez

Lambda the Ultimate
TWiki.org

Functional Heap

Problem

A heap is data structure that in its basic form supports the operations insert and delete-min. More advanced heaps also support merge.

Solution

One solution is to use pairing heaps. Pairing heaps supports make-empty, empty?, find-min, insert, merge and delete-min.

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

Discussion

For applications that do not use merge, pairing heaps are almost as fast as splay trees. For applications that use merge, pairing heaps are much faster.

The operations have the following running times:

 Time               worst case   amortized

  make-empty         O(1)         O(1)
  empty?             O(1)         O(1)
  find-min           O(1)         O(1)   
  insert             O(1)         O(log n) \ conjectured better: O(1)
  merge              O(1)         O(log n) /
  delete-min         O(n)         O(log n) 

-- JensAxelSoegaard - 17 Apr 2004

CookbookForm
TopicType: Recipe
ParentTopic: DataStructureRecipes
TopicOrder:

 
 
Copyright © 2004 by the contributing authors. All material on the Schematics Cookbook web site is the property of the contributing authors.
The copyright for certain compilations of material taken from this website is held by the SchematicsEditorsGroup - see ContributorAgreement & LGPL.
Other than such compilations, this material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest