Finding the lowest leftmost node in BST

Hello ... I dont know why I cannot get the lowest leftmost node in BST: segment fault

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
goToLeaf=root;
//now traversing right subtree from root node
else if(strcmp(curr->barcode, traverse->barcode)>0){
		path='R';
		
		traverse=traverse->right;
		save=traverse;
		cout<<"Right subtree exists. Value in right subtree"<<endl;
		
		
		
		while(goToLeaf!=NULL){
			//prev=goToLeaf;
			goToLeaf=goToLeaf->right;
			if(goToLeaf->right->right==NULL){
				//goToLeaf=goToLeaf->left;
     
                           
			   strcpy(goToLeaf->barcode,goToLeaf->left->barcode);
				cout<<"val: "<<goToLeaf->barcode<<endl;
				break;}
				
			}


Need this to delete node in two subtreed right subtree
Last edited on
1
2
3
while(goToLeaf!=NULL){
	goToLeaf=goToLeaf->right; //¿what if 'goToLeaf' is NULL now?
	if(goToLeaf->right->right==NULL){ //¿what if 'goToLeaf->right' is NULL? 
what should I do? I need to find min value of the right subtree
Topic archived. No new replies allowed.