Editing Binomial heap

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 25: Line 25:
  
 
==Merging==
 
==Merging==
Let two binomial heaps be denoted <math>A</math> and <math>B</math>, with sizes <math>n</math> and <math>m</math>, respectively. Let <math>A_k</math> denote <math>A</math>'s power-of-two tree of size <math>2^k</math>, if it has one, and <math>B_k</math> denote likewise a power-of-two tree of <math>B</math>. We want to create a new binomial heap <math>S</math> that contains all the nodes from either <math>A</math> or <math>B</math> and has size <math>m+n</math>. After this operation, <math>A</math> and <math>B</math> will no longer exist as binomial heaps.
+
Let two binomial heaps be denoted <math>A</math> and <math>B</math>, with sizes <math>n</math> and <math>m</math>, respectively. Let <math>A_k</math> denote <math>A</math>'s power-of-two tree of size <math>2^k</math>, if it has one, and <math>B_k</math> denote likewise a power-of-two tree of <math>B</math>. We want to create a new binomial tree <math>S</math> that contains all the nodes from either <math>A</math> or <math>B</math> and has size <math>m+n</math>. After this operation, <math>A</math> and <math>B</math> will no longer exist as binomial heaps.
  
 
(In theory, we could create a new binomial heap <math>S</math> that contained all the elements from both <math>A</math> and <math>B</math> ''without'' also destroying <math>A</math> and <math>B</math>. However, this would require copying over all the data from both heaps, which would take linear time (in the sum of their sizes). This would then be no more efficient than simply using the [[binary heap]]s. For this reason, we assume we usually do not want to do this.)
 
(In theory, we could create a new binomial heap <math>S</math> that contained all the elements from both <math>A</math> and <math>B</math> ''without'' also destroying <math>A</math> and <math>B</math>. However, this would require copying over all the data from both heaps, which would take linear time (in the sum of their sizes). This would then be no more efficient than simply using the [[binary heap]]s. For this reason, we assume we usually do not want to do this.)

Please note that all contributions to PEGWiki are considered to be released under the Attribution 3.0 Unported (see PEGWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)

Templates used on this page: