亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? binarytree.c

?? Binary Search Tree - with additional recursion functions (smallest, parent & successor) etc
?? C
字號:
// BinaryTree.c// file is the implementation of a binary search tree.#include <stdlib.h> // for malloc#include "BinaryTree.h"// Defines #define TRUE 1#define FALSE 0typedef struct Node{   Item item;   Key key;   struct Node *left;   // if left == NULL , it means it has no left son   struct Node *right;   // if right == NULL , it means it has no right son} *ptrNode;struct tree{   ptrNode root;};int succ;//helper functionsstatic BOOL delNode(Tree tree, Key key);static ptrNode find_parent(ptrNode root, Key key);static ptrNode find_succ(ptrNode root);static ptrNode find_small(ptrNode root);static void DestoryTree(Tree tree);// ---------------------------------------------------------static ptrNode search(ptrNode subtree, Key key);static void traversePre(ptrNode subtree, PerItemFunc pFunc);static void traverseIn(ptrNode subtree,  PerItemFunc pFunc);static void traversePost(ptrNode subtree,PerItemFunc pFunc);void deleteTree(Tree tree){   DestoryTree(tree);}int deleteNode(Tree tree, Key key){   succ=delNode(tree,key);   return succ;}Tree CreateTree(){   return calloc(1,sizeof(struct tree));}Item *Find(Tree tree, Key key)// searches a node, given its key, in the tree and// returns the appropriate Item address.// returns NULL if it's not found{   ptrNode pNode = search(tree->root,key);   if (!pNode)      return NULL;   return &(pNode->item);}static ptrNode search(ptrNode root, Key key){   if (root)	 {      if (!EQ(key,root->key))         return root;												// we've found it      if (EQ(key,root->key) < ZERO)         return search(root->left, key);      else if (EQ(key,root->key) > ZERO)         return search(root->right, key);   }   return NULL;													// the sub-tree was empty}void traversePreOrder(Tree tree, PerItemFunc pFunc){   traversePre(tree->root, pFunc);}void traverseInOrder(Tree tree, PerItemFunc pFunc){   traverseIn(tree->root, pFunc);}void traversePostOrder(Tree tree, PerItemFunc pFunc){   traversePost(tree->root, pFunc);}static void traversePre(ptrNode root,                        PerItemFunc pFunc){   if (root) // if ptr is not NULL (i.e., there is a node)   {      pFunc(&root->item);      traversePre(root->left, pFunc);      traversePre(root->right, pFunc);   }}static void traverseIn(ptrNode root,                       PerItemFunc pFunc){   if (root) // if ptr is not NULL (i.e., there is a node)   {      traverseIn(root->left, pFunc);      pFunc(&root->item);      traverseIn(root->right, pFunc);   }}static void traversePost(ptrNode root,                         PerItemFunc pFunc){   if (root) // if ptr is not NULL (i.e., there is a node)   {      traversePost(root->left, pFunc);      traversePost(root->right, pFunc);      pFunc(&root->item);   }}void add(Tree tree, Key key, Item item){   ptrNode subtree;   //crate new node   ptrNode newNode = malloc(sizeof(struct Node));   if (!newNode)   {      ERROR();      return;   }		//fill it with data   newNode->key = key;   newNode->item = item;   newNode->left = newNode->right = NULL;   subtree = tree->root; //start from beginning   if (!tree->root) // Is it an empty tree?   {      tree->root = newNode;      return;   }		while (1)   {      if (EQ(key, subtree->key) < ZERO) // add to left sub-tree      {        if ( subtree->left == NULL )        {            subtree->left = newNode;            return;        }         subtree = subtree->left;      }     else //add to right sub-tree      {        if ( subtree->right == NULL )        {            subtree->right = newNode;            return;        }        subtree = subtree->right;      }   }}//===========================================================================// is a child of the recursion function find_succ() to find the// succsessor.//===========================================================================static ptrNode find_small(ptrNode root){	if(root)	{		if(root->left == NULL)		{			return root;		}		else		{			return find_small(root->left);		}	}	return NULL;}//===========================================================================// find succ of Item that we want delete//===========================================================================static ptrNode find_succ(ptrNode root){	return (root->right ? find_small(root->right) : NULL);}//===========================================================================// this function find in a recursion way the father// of the actually Item//===========================================================================static ptrNode find_parent(ptrNode root, Key key){	if(root)	{		if( (root->left != NULL && EQ(root->left->key, key) == ZERO ) ||				(root->right != NULL && EQ(root->right->key, key) == ZERO))		{			return root;		}		if(EQ(root->key, key) > ZERO)		{			return find_parent(root->left, key);		}		else if (EQ(root->key, key) < ZERO)		{			return find_parent(root->right, key);		}	}	return NULL;}//===========================================================================// is the main function to set all variables for the delete procedure.//===========================================================================static BOOL delNode(Tree tree, Key key){	ptrNode root = tree->root;	ptrNode pDel = NULL;	ptrNode father = NULL;	ptrNode succ = NULL;	ptrNode fsucc = NULL;	ptrNode tmp = NULL;	if (!tree->root)	{		return FALSE;	}	// find the spec. Item	pDel = search(root, key);	if (pDel == NULL)	{		return FALSE;	}	father = find_parent(root, key);	// if all our Nodes smaller then root	if ( root->right == NULL )	{		tree->root = pDel->left;		free(pDel);		return TRUE;	} // ups they are all greater!	else if ( root->left  == NULL )	{		tree->root = pDel->right;		free(pDel);		return TRUE;	}	if (pDel->left == NULL && pDel->right == NULL)	{		if (EQ(key,father->key) == ZERO_GREATER) //if the son is on the right of the father		{			father->right = NULL;		}		else //if it's on the left		{			father->left = NULL;		}	}	else if (pDel->left != NULL && pDel->right == NULL)	{		if (EQ(key,father->key) == ZERO_GREATER) //if the son is on the right of the father		{			father->right = pDel->left;		}		else //if it's on the left		{			father->left = pDel->left;		}	}	else //if pDel has two sons, or son on the right only	{		succ = find_succ(pDel);		fsucc = find_parent(root, succ->key);		if (EQ(root->key,key) == ZERO) //  the node to delete is the root of the tree		{			father = pDel;			succ = find_succ(pDel);			fsucc = find_parent(pDel,succ->key);			if (succ == pDel->right)			{				succ->right = succ->right;			}			else			{				succ->right = pDel->right;				fsucc->left = NULL;			}			succ->left  = pDel->left;			tree->root = succ;			free(pDel);			return TRUE;		}		else if (EQ(key,father->key) == 1)//if the son is on the right of the father		{			father->right = succ;		}		else //if it's on the left		{			father->left = succ;		}		tmp = pDel->left;		if(EQ(fsucc->key,pDel->key) == ZERO)		{			fsucc->left = NULL;			fsucc->right = NULL;		}		else		{			fsucc->left = succ->right;		}		//if the succesor is not the son of pDel		succ->left = tmp;		succ->right = pDel->right;	}	tmp = NULL;	free(pDel);	return TRUE;}static void DestoryTree(Tree tree){	while (find_small(tree->root))	{		delNode(tree,find_small(tree->root)->key);	}	free(tree);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产视频一区在线播放| 亚洲国产综合色| 欧美高清一级片在线| 不卡av电影在线播放| 国产在线乱码一区二区三区| 亚洲成人免费在线观看| 一区二区三区自拍| 亚洲一区二区三区爽爽爽爽爽| 国产精品嫩草影院com| 国产欧美日韩麻豆91| 国产日本欧洲亚洲| 国产精品久久久久久久第一福利| 欧美国产国产综合| 最新国产の精品合集bt伙计| 亚洲欧美日韩人成在线播放| 亚洲视频一区二区在线| 一区二区三区在线免费视频| 亚洲小少妇裸体bbw| 免费观看91视频大全| 激情文学综合网| 成人自拍视频在线| 在线区一区二视频| 91极品视觉盛宴| 2023国产一二三区日本精品2022| 欧美一区二区视频在线观看2022| 在线不卡欧美精品一区二区三区| 欧美精三区欧美精三区| 日韩一区二区电影在线| www国产亚洲精品久久麻豆| 亚洲国产成人午夜在线一区 | 国产农村妇女毛片精品久久麻豆 | 91久久精品一区二区三| 91精品国产乱码| 久久女同精品一区二区| 亚洲乱码国产乱码精品精的特点 | 色就色 综合激情| 在线看日韩精品电影| 欧美日韩中文另类| 日韩精品专区在线影院观看| 中文字幕乱码久久午夜不卡| 亚洲成人av免费| 美女网站色91| av电影在线不卡| 欧美一级夜夜爽| 国产精品日产欧美久久久久| 亚洲丶国产丶欧美一区二区三区| 国模大尺度一区二区三区| 在线观看国产一区二区| 久久久久国产精品麻豆ai换脸 | 91网站最新网址| 日韩免费高清视频| 日韩欧美第一区| 亚洲靠逼com| 亚洲成人手机在线| 国模无码大尺度一区二区三区| 国产精品入口麻豆原神| 91久久久免费一区二区| www.性欧美| 久久久www免费人成精品| 日本麻豆一区二区三区视频| 久久影院视频免费| 国产精品视频观看| 欧美性三三影院| 精品理论电影在线观看 | 亚洲欧洲精品一区二区三区不卡| 91蜜桃传媒精品久久久一区二区| 一区二区视频在线| 国产欧美一区二区精品久导航| 亚洲一区二区美女| 国产在线国偷精品免费看| 欧美专区在线观看一区| 日韩免费看的电影| 日韩亚洲欧美中文三级| 99精品视频一区| 色综合夜色一区| 久久精品日韩一区二区三区| 欧美精品一区二区三区蜜臀| 91久久精品一区二区三| 久久精品国产99| 亚洲成人精品一区| 亚洲精品午夜久久久| 国产视频911| 精品国产网站在线观看| 欧美成人video| 欧美吻胸吃奶大尺度电影| 国产**成人网毛片九色| 欧美日韩一级大片网址| 蜜臀av一区二区三区| 国产农村妇女毛片精品久久麻豆 | 日韩欧美国产系列| 国产成人精品一区二| 亚洲主播在线观看| 国产剧情一区二区三区| 久久精品国产一区二区三| 美女视频免费一区| 99精品欧美一区二区三区综合在线| 国产在线不卡一区| 日本久久一区二区| 日韩va欧美va亚洲va久久| 亚洲国产精品久久久久婷婷884| 一区二区三区精品在线观看| 欧美性感一区二区三区| 成人中文字幕合集| 日韩电影在线观看电影| 3atv一区二区三区| 久久精品久久99精品久久| 久久久蜜桃精品| 色哟哟国产精品| 国产精品久久久久9999吃药| 亚洲一区二区三区四区中文字幕| 国产精品一区二区三区四区| 欧美精品一卡二卡| 亚洲综合精品久久| 成人黄色网址在线观看| 欧美性猛片aaaaaaa做受| 欧美电影免费观看高清完整版在线 | 国产婷婷一区二区| 午夜国产精品一区| 色哟哟国产精品免费观看| 欧美色图在线观看| 国产成人在线视频网址| 亚洲一区二区精品视频| 亚洲精品在线免费播放| 欧洲国内综合视频| 国产精品亚洲视频| 日韩电影在线免费观看| 中文字幕字幕中文在线中不卡视频| 欧美一区二区三级| 在线一区二区三区做爰视频网站| 国产乱码字幕精品高清av| 九九**精品视频免费播放| 日韩欧美一区电影| 91九色02白丝porn| 成人久久视频在线观看| 青青国产91久久久久久| 亚洲线精品一区二区三区八戒| 亚洲国产经典视频| 337p日本欧洲亚洲大胆色噜噜| 精品视频免费在线| 91丨国产丨九色丨pron| 国产xxx精品视频大全| 免费成人在线影院| 婷婷成人综合网| 亚洲一区二区三区四区的 | 久久成人羞羞网站| 亚洲国产欧美一区二区三区丁香婷| 亚洲国产高清在线| 国产欧美一区二区精品婷婷| 久久久噜噜噜久久中文字幕色伊伊| 8x福利精品第一导航| 欧美日韩一级视频| av在线不卡观看免费观看| 精品国偷自产国产一区| 日韩国产精品91| 色狠狠色狠狠综合| 樱桃视频在线观看一区| 日本精品一区二区三区四区的功能| 一区二区国产盗摄色噜噜| 欧美日韩三级视频| 久久国产综合精品| 国产日韩欧美a| 色噜噜夜夜夜综合网| 婷婷夜色潮精品综合在线| 精品欧美一区二区在线观看| 国产在线日韩欧美| 亚洲精品中文字幕乱码三区| 欧美区视频在线观看| 国产在线国偷精品免费看| 国产精品久99| 欧美老女人在线| 国内精品伊人久久久久影院对白| 国产精品私房写真福利视频| 欧美伊人久久大香线蕉综合69 | 国产精品久久久久aaaa樱花| 91久久免费观看| 久热成人在线视频| 日韩伦理免费电影| 538prom精品视频线放| 国产成人亚洲综合色影视| 亚洲综合久久av| 久久久综合视频| 欧美性做爰猛烈叫床潮| 国产一区二区中文字幕| 一区二区三区国产精品| www一区二区| 欧美三级电影一区| 国产精品中文字幕一区二区三区| 亚洲精品一二三区| 久久久影视传媒| 欧美日韩一二三区| a4yy欧美一区二区三区| 奇米888四色在线精品| 亚洲人精品一区| 丁香激情综合国产| 日韩一区欧美一区| 日韩手机在线导航| av在线免费不卡| 国模无码大尺度一区二区三区| 亚洲免费观看高清完整版在线| 日韩欧美一级在线播放|