コード例 #1
0
ファイル: BinTree.cpp プロジェクト: JinfengChen/Sniffles
void BinTree::del(int key) {
	tree_node *parent, *location;

	if (root == NULL) {
		std::cout << "Tree empty" << std::endl;
		return;
	}

	find(key, &parent, &location);
	if (location == NULL) {
		std::cout << "Item not present in tree" << std::endl;
		return;
	}

	if (location->left == NULL && location->right == NULL) {
		case_a(parent, location);
	}
	if (location->left != NULL && location->right == NULL) {
		case_b(parent, location);
	}
	if (location->left == NULL && location->right != NULL) {
		case_b(parent, location);
	}
	if (location->left != NULL && location->right != NULL) {
		case_c(parent, location);
	}
	delete location;
}
コード例 #2
0
ファイル: bst.c プロジェクト: jithesh92/Btech-Labs
del(int item) 
{ 
	struct node *parent,*location; 
	if(root==NULL) 
	{ 
		printf("\ntree empty\n"); 
		return; 
	} 
	find(item,&parent,&location); 
	if(location==NULL) 
	{ 
		printf("\nitem is not present in tree\n"); 
		return; 
	} 
	if((location->lchild==NULL)&&(location->rchild==NULL)) 
	case_a(parent,location); 
	if((location->lchild!=NULL)&&(location->rchild==NULL)) 
	case_b(parent,location); 
	if((location->lchild==NULL)&&(location->rchild!=NULL)) 
	case_b(parent,location); 
	if((location->lchild!=NULL)&&(location->rchild!=NULL)) 
	case_c(parent,location); 
	free(location); 
	printf("\ndeleted\n"); 
} 
コード例 #3
0
ファイル: BST.C プロジェクト: b-rajarshi/code_ol_judges
del(int item)
{
	struct node *parent,*location;
	if(root==NULL)
	{
		printf("Tree empty");
		return;
	}

	find(item,&parent,&location);
	if(location==NULL)
	{
		printf("Item not present in tree");
		return;
	}

	if(location->lchild==NULL && location->rchild==NULL)
		case_a(parent,location);
	if(location->lchild!=NULL && location->rchild==NULL)
		case_b(parent,location);
	if(location->lchild==NULL && location->rchild!=NULL)
		case_b(parent,location);
	if(location->lchild!=NULL && location->rchild!=NULL)
		case_c(parent,location);
	free(location);
}/*End of del()*/
コード例 #4
0
ファイル: internal_printf.c プロジェクト: abombard/minishell3
static uint8_t	switch_case(t_buffer *dst, char c, va_list ap, t_flags *flag)
{
	if (c == 'd' || c == 'i')
		case_nbr(dst, ap, flag);
	else if (c == 'o')
		case_o(dst, ap, flag);
	else if (c == 'u')
		case_u(dst, ap, flag);
	else if (c == 'x')
		case_x(dst, ap, flag);
	else if (c == 'X')
		case_x_maj(dst, ap, flag);
	else if (c == 'p')
		case_p(dst, ap, flag);
	else if (c == 's')
		case_s(dst, ap, flag);
	else if (c == 'c')
		case_c(dst, ap, flag);
	else
		return (0);
	return (1);
}
コード例 #5
0
ファイル: NEWTHRD.CPP プロジェクト: dhruv7294/DataStructure
void del(int item)
{
	if(head==NULL)
	{
		printf("Tree empty");
		return;
	}
	find(item);
	if(Loc==NULL)
	{
		printf("Item not present in tree");
		return;
	}

	if(Loc->left==thread && Loc->right==thread) //  for zero child
		case_a(head,Par,Loc);
	if(Loc->left==link && Loc->right==thread) // for one left child
		case_b(head,Par,Loc);
	if(Loc->left==thread && Loc->right==link) // for one right child
		case_b(head,Par,Loc);
	if(Loc->left==link && Loc->right==link) // for two child left and right
		case_c(head,Par,Loc);
}