当前位置: 首页>>代码示例>>C++>>正文


C++ BST::deleteBSTNode方法代码示例

本文整理汇总了C++中BST::deleteBSTNode方法的典型用法代码示例。如果您正苦于以下问题:C++ BST::deleteBSTNode方法的具体用法?C++ BST::deleteBSTNode怎么用?C++ BST::deleteBSTNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BST的用法示例。


在下文中一共展示了BST::deleteBSTNode方法的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;
}
开发者ID:AlkaYadav,项目名称:DataStructures,代码行数:101,代码来源:main.cpp


注:本文中的BST::deleteBSTNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。