本文整理汇总了C++中BST::deleteBST方法的典型用法代码示例。如果您正苦于以下问题:C++ BST::deleteBST方法的具体用法?C++ BST::deleteBST怎么用?C++ BST::deleteBST使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BST
的用法示例。
在下文中一共展示了BST::deleteBST方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
cout<<endl<<"Do you want to enter more data"<<endl;
cin>>ins;
}while(ins=='y'||ins=='Y');
break;
case 2:
cout<<endl<<"Number of nodes in BST are:"<<bst.count()<<endl;
break;
case 3:
cout<<endl<<"Number of binary trees possible with count"<<bst.count()<<" is :"<<bst.catalanNumber(bst.count())<<endl;
break;
case 4:
cout<<endl<<"Inorder"<<endl;
bst.inorder();
break;
case 5:
cout<<endl<<"Preorder"<<endl;
bst.preorder();
break;
case 6:
cout<<endl<<"Postorder"<<endl;
bst.postorder();
break;
case 7:
cout<<endl<<"Postorder Iterative"<<endl;
bst.postorderIterative();
break;
case 8:
cout<<endl<<"Enter the sum to check in BST"<<endl;
cin>>sum;
cout<<endl<<"Result:"<<bst.hasPathSum(sum)<<endl;
break;
case 9:
cout<<endl<<"Diameter of BST:"<<bst.diameter();
break;
case 10:
cout<<endl<<"Minimum value in BST:"<<bst.minimum()<<endl;
break;
case 11:
cout<<endl<<"Enter the element you want to search:"<<endl;
cin>>data;
cout<<bst.search(data);
break;
case 12:
cout<<endl<<"Enter the node data to find parent of:"<<endl;
cin>>data;
cout<<endl<<"Parent is:"<<endl<<bst.parentNode(data)<<endl;
break;
case 13:
cout<<"Enter node to find Tree successor for:"<<endl;
cin>>data;
cout<<bst.treeSuccessor(data);
break;
case 14:
cout<<endl<<"Maximum depth of BST:"<<bst.depth()<<endl;
break;
case 15:
bst.insertRandomForSecondBST(50);
bst.insertRandomForSecondBST(40);
bst.insertRandomForSecondBST(60);
bst.insertRandomForSecondBST(30);
bst.insertRandomForSecondBST(45);
bst.insertRandomForSecondBST(55);
bst.insertRandomForSecondBST(70);
bst.insertRandomForSecondBST(25);
bst.insertRandomForSecondBST(20);
bst.insertRandomForSecondBST(46);
bst.insertRandomForSecondBST(47);
bst.insertRandomForSecondBST(48);
cout<<endl<<"isBST:"<<bst.isBST()<<endl;
break;
case 16:
cout<<endl<<"Enter the nodes for finding lowest common ancestor"<<endl;
cin>>node1>>node2;
cout<<endl<<"Lowest common ancestor of "<<node1<<"and"<<node2<<"is:"<<bst.lowestCommonAncestor(node1,node2);
break;
case 17:
cout<<"Checking for similarity of two BSTs:"<<endl;
cout<<endl<<"Result of checking similarity:"<<bst.checkTreesSimilarity()<<endl;
break;
case 18:
bst.printAllPossiblePaths();
break;
case 19:
cout<<endl<<"Enter the node you want to delete"<<endl;
cin>>data;
bst.deleteBSTNode(data);
cout<<endl<<"Now the tree is"<<endl;
bst.inorder();
break;
case 20:
cout<<endl<<"Deleting BST:"<<endl;
bst.deleteBST();
cout<<endl<<"Number of nodes in BST are:"<<bst.count()<<endl;
break;
}
cout<<endl<<"Press y to continue"<<endl;
cin>>ans;
}while(ans=='y'||ans=='Y');
return 0;
}