0

HEY i am trying to resolve my problem here is the code and the error

2 [main] PA4 2768 exception::handle: Exception: STATUS_ACCESS_VIOLATION
2331 [main] PA4 2768 open_stackdumpfile: Dumping stack trace to PA4.exe.stackdump

Function

void BinarySearchTree::Insert(int val)
{
	BSTNode *node, *p;
	cout<<node->GetLeftChild();
	cout<<node->GetLeftChild();
	p=root;
	node->setData(val);
	node->SetLeftChild(0);
	node->SetRightChild(0);
	if(p==0)
	{
		root=node;
	}
	else
	{
		while(p)
		{
			if(p->getData()==val)
				return ;
			else if(p->getData()<val)
			{
				p->SetRightChild(node);
			}
			else
				p->SetLeftChild(node);
		}
	}
}

driver code

int main()
{
	int val=0;
	BinarySearchTree tree;
	cout<<"Enter the value to be inserted";
	cin>>val;
	cout<<tree.GetRoot();
	tree.Insert(val);
        return 0;
}
4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by firstPerson
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.