A skew heap (or self-adjusting heap) is a heap data structure implemented as a binary tree. Skew heaps are advantageous because of their ability to merge more quickly than binary heaps. In contrast with binary heaps, there are no structural constraints, so there is no guarantee that the height of the tree is logarithmic. Only two conditions must be satisfied: The general heap order must be enforced Every operation (add, remove_min, merge) on two skew heaps must be done using a special skew heap merge. A skew heap is a self-adjusting form of a leftist heap which attempts to maintain balance by unconditionally swapping all nodes in the merge path when merging two heaps. (The merge operation is also used when adding and removing values.) With no structural constraints, it may seem that a skew heap would be horribly inefficient. However, amortized complexity analysis can be used to demonstrate that all operations on a skew heap can be done in O(log n). In fact, with denoting the golden ratio, the exact amortized complexity is known to be logφ n (approximately 1.44 log2 n). Definition Skew heaps may be described with the following recursive definition: A heap with only one element is a skew heap. The result of skew merging two skew heaps and is also a skew heap. Operations Merging two heaps When two skew heaps are to be merged, we can use a similar process as the merge of two leftist heaps: Compare roots of two heaps; let be the heap with the smaller root, and q be the other heap. Let be the name of the resulting new heap. Let the root of r be the root of (the smaller root), and let r's right subtree be p's left subtree. Now, compute r's left subtree by recursively merging p's right subtree with q. template<class T, class CompareFunction> SkewNode<T>* CSkewHeap<T, CompareFunction>::_Merge(SkewNode<T>* root_1, SkewNode<T>* root_2) { SkewNode<T>* firstRoot = root_1; SkewNode<T>* secondRoot = root_2; if (firstRoot == NULL) return secondRoot; else if (secondRoot == NULL) return firstRoot; if (sh_compare->Less(firstRoot->key, secondRoot->key)) { SkewNode<T>* tempHeap = firstRoot->rightNode; firstRoot->rightNode = firstRoot->leftNode; firstRoot->leftNode = _Merge(secondRoot, tempHeap); return firstRoot; } else return _Merge(secondRoot, firstRoot); } Before: after Non-recursive merging Alternatively, there is a non-recursive approach which is more wordy, and does require some sorting at the outset. Split each heap into subtrees by cutting every path. (From the root node, sever the right node and