main() { struct node *root = NULL; root = build123(); printTree(root); }
int main(){ int s; struct node* root = build123(); printTree(root); }
void test() { node_t* root = build_n_tree(30, 0); bfs(root); node_t* root2 = build_n_tree(50, 0); bfs(root2); node_t* root3 = build_n_tree(90, 0); bfs(root3); node_t* root4 = build_n_tree(1000, 0); bfs(root4); node_t* root5 = build123(); bfs(root5); printf("balanced? %d\n", is_balanced(root)); printf("balanced? %d\n", get_height_balanced(root)); printf("balanced? %d\n", is_balanced(root2)); printf("balanced? %d\n", get_height_balanced(root2)); printf("balanced? %d\n", is_balanced(root3)); printf("balanced? %d\n", get_height_balanced(root3)); printf("balanced? %d\n", is_balanced(root4)); printf("balanced? %d\n", get_height_balanced(root4)); printf("balanced? %d\n", is_balanced(root5)); printf("balanced? %d\n", get_height_balanced(root5)); }
main() { struct node* head = build123(); Push(&head, 0); printdata(head); InsertNth( &head, 0, 299); printdata(head); InsertNth( &head, 3, 845); printdata(head); }
main() { struct node* head = build123(); printdata(head); printf("1 occur %d times\n",count(head,1)); printf("3 occur %d times\n",count(head,3)); printf("10 occur %d times\n",count(head,10)); printf("0th element is %d \n",GetNth(head,0)); DeleteList(&head); }
main() { struct node* head = build123(); printdata(head); printf("0th element is %d \n",GetNth(head,0)); printf("value = %d\n",pop(&head)); printdata(head); printf("value = %d\n",pop(&head)); printdata(head); printf("value = %d\n",pop(&head)); printdata(head); printf("value = %d\n",pop(&head)); printdata(head); }
int main(int argc, char* argv[]) { struct node* root = build123(); // This is not a binary search tree. root->left->left = NewNode(33); root->left->right = NewNode(28); root->left->right->left = NewNode(92); root->right->right = NewNode(4); root->right->right->right = NewNode(5); root->right->right->right->left = NewNode(100); int count = size(root); printf("%d\n", count); }
main() { struct node* head = build123(); printdata(head); }
/*Test function for build123()*/ void testBuild123() { struct node* root = build123(); printf("Root node is %d \n",root->data); printf("Left node is %d \n",(root->left)->data); printf("Right node is %d \n",(root->right)->data); }