TreeNode * Btree::contruct_tree() { TreeNode *root=NULL; TreeNode *leaf=NULL; Btree btree; /* //Test case1: root=btree.insert(1); //insert root leaf=btree.insert(2,root); */ //Test case2: root=btree.insert(5); //insert root //left tree leaf=btree.insert(4,root); leaf=btree.insert_nocompare(11,leaf); btree.insert_nocompare(7,leaf); btree.insert_nocompare(2,leaf); //right tree leaf=btree.insert_nocompare(8,root); btree.insert_nocompare(13,leaf); leaf=btree.insert_nocompare(4,leaf); btree.insert_nocompare(5,leaf); leaf=btree.insert_nocompare(1,leaf); return root; }
TreeNode * Btree::contruct_tree() { TreeNode *root=NULL; TreeNode *leaf=NULL; Btree btree; /* //Test case1: root=btree.insert(1); //insert root leaf=btree.insert(2,root); */ //Test case2: /*root=btree.insert(5); //insert root //left tree leaf=btree.insert(4,root); leaf=btree.insert_nocompare(11,leaf); btree.insert_nocompare(7,leaf); btree.insert_nocompare(2,leaf); //right tree leaf=btree.insert_nocompare(8,root); btree.insert_nocompare(13,leaf); leaf=btree.insert_nocompare(4,leaf); leaf=btree.insert_nocompare(1,leaf);*/ //Test case3: root=btree.insert(3); //insert root //left tree leaf=btree.insert_nocompare(9,root); //btree.insert_nocompare('#'-'0',leaf); //btree.insert_nocompare('#'-'0',leaf); //right tree leaf=btree.insert_nocompare(20,root); btree.insert_nocompare(15,leaf); btree.insert_nocompare(7,leaf); /*//Test case3:Only left tree root=btree.insert(1); //insert root //left tree btree.insert_nocompare('#'-'0',root); leaf=btree.insert_nocompare(2,root); btree.insert_nocompare('#'-'0',leaf); leaf=btree.insert_nocompare(3,leaf); btree.insert_nocompare('#'-'0',leaf); leaf=btree.insert_nocompare(4,leaf); btree.insert_nocompare(5,leaf);*/ /*//Test case4: root=btree.insert(-8); //insert root //left tree btree.insert_nocompare(0,root); leaf=btree.insert_nocompare(3,root); leaf=btree.insert_nocompare(-8,leaf); leaf=btree.insert_nocompare(-1,leaf); btree.insert_nocompare(8,leaf);*/ return root; }