⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minleftlisttree.cpp

📁 插入和删除最小元素操作
💻 CPP
字号:
// MinLeftistTree.cpp: implementation of the MinLeftistTree class.
//
//////////////////////////////////////////////////////////////////////

#include "MinLeftlistTree.h"

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

LeftlistNode* MinLeftlistTree::MinUnion(LeftlistNode *a, LeftlistNode *b )
{
	if( a->data.key > b->data.key )
	{
		LeftlistNode *t = a;
		a = b;
		b = t;
	}
	if( !a->RightChild)
		a->RightChild = b;
	else
		a->RightChild = MinUnion( a->RightChild, b );

	if(!a->LeftChild)
	{
		a->LeftChild = a->RightChild;
		a->RightChild = 0;
	}
	else if( a->LeftChild->shortest < a->RightChild->shortest )
	{
		LeftlistNode *t = a->LeftChild;
		a->LeftChild = a->RightChild;
		a->RightChild = t;
	}

	if( !a->RightChild )
		a->shortest = 1;
	else
		a->shortest = a->RightChild->shortest + 1;
	return a;
}

void MinLeftlistTree::Insert( const element& x  )
{
}

void MinLeftlistTree::MinCombine(MinLeftlistTree* b)
{
	if(!root) 
		root = b->root;
	else if(b->root) 
		root = MinUnion(root,b->root);
	b->root = 0;
}

element* MinLeftlistTree::Delete( element& del )
{
	LeftlistNode* empty = 0;
	if( root == empty )
	{
		return 0;
	}

	return &del;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -