answersLogoWhite

0

What else can I help you with?

Related Questions

Explain the three types of tree traversals with illustration?

Inorder Traversal void inorder(tree t) { if(t == NULL) return; inorder(t->left); printf("%d ", t->val); inorder(t->right); }Preorder Traversalvoid preorder(tree t) { if(t == NULL) return; printf("%d ", t->val); preorder(t->left); preorder(t->right); } Postorder Traversalvoid postorder(tree t) { if(t == NULL) return; postorder(t->left); postorder(t->right); printf("%d ", t->val);


What is the difference between traversal and search?

Traversal simply means moving from one node to the next. Generally one searches by traversing the list, comparing each node's data with a given datum, either to return a pointer to a single matching node, or to return a list of matching nodes (copied from the list being searched), or simply to collect data about the matching nodes (such as a count of all the matching nodes).


Write the algorithm for in order traversal?

Inorder(p) { If p = nil return; Inorder(p.left) process(p.data) Inorder(p.right) }


Write a c program to create a binary tree?

#include<stdio.h> #include<stdlib.h> //#include<conio.h> struct treenode { int ele; struct treenode *l_child, *r_child; }; struct treenode *insert_node(struct treenode *t,int a); void TraverseInorder(struct treenode *t); void TraversePreorder(struct treenode *t); void TraversePostorder(struct treenode *t); /*main function*/ int main() { struct treenode *root_node = NULL; int num,value; int choice; //clrscr(); printf("----------------------------------------------------\n"); printf("\t\t\tMENU\n"); printf("-----------------------------------------------------\n"); printf("[1] Create a Binary Tree and Use Inorder Traversal\n"); printf("[2] Create a Binary Tree and Use Preorder Traversal\n"); printf("[3] Create a Binary Tree and Use Postorder Traversal\n"); printf("-----------------------------------------------------\n"); printf("Enter your choice:"); scanf("%d",&choice); if(choice>0 & choice<=3) { printf("\nEnter the number of nodes:"); scanf("%d",&num); while(num-- > 0) { printf("\n\nEnter the data value:"); scanf("%d",&value); root_node = insert_node(root_node,value); } switch(choice) { case 1: printf("\n\nBinary tree using Inorder Traversal : "); TraverseInorder(root_node); getch(); break; case 2: printf("\n\nBinary tree using Preorder Traversal : "); TraversePreorder(root_node); getch(); break; case 3: printf("\n\nBinary tree using Postorder Traversal : "); TraversePostorder(root_node); getch(); break; default: printf("Invalid Choice"); break; } } } /*end main*/ /* Function to create a Binary Tree of integers data */ struct treenode *insert_node(struct treenode *t,int a) { struct treenode *temp_node1,*temp_node2; if(t NULL) { printf("Value cannot be allocated.\n"); exit(0); } temp_node2->ele = a; temp_node2->l_child=temp_node2->r_child = NULL; } } return(t); } /* Function for Traversing the binary tree in inorder. */ void TraverseInorder(struct treenode *t) { if(t != NULL) { TraverseInorder(t->l_child); printf("%d\t",t->ele); in_order(t->r_child); } } /* Function for Traversing the binary tree in preorder. */ void TraversePreorder(struct treenode *t) { if(t != NULL) { printf("%d\t",t->ele); TraversePreorder(t->l_child); TraversePreorder(t->r_child); } } /* Function for Traversing the binary tree in postorder. */ void TraversePostorder(struct treenode *t) { if(t != NULL) { TraversePostorder(t->l_child); TraversePostorder(t->r_child); printf("%d\t",t->ele); } }


What event happened during Cleopatra's childhood?

The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).The major event that happened during Cleopatra's childhood was her father's exile and return. This return resulted in the deaths of Cleopatra's sister and her husband (and more than likely many others as well).


How do you write a c program for expression tree traversal?

#include<stdio.h> #include<conio.h> #define MAX 30 typedef struct ETREE { struct ETREE *lc; char data; struct ETREE *rc; }etree; typedef struct STACK { etree *ST[MAX]; int top; }stack; void initialize_stack(stack *sp) { sp->top = -1; } int isstackempty(int top) { if(top MAX - 1) return(1); else return(0); } void push(stack *sp,etree *x) { if(!isstackfull(sp->top)) { sp->top = sp->top + 1; sp->ST[sp->top] = x; } else printf("\n\nStack full!!"); } etree *pop(stack *sp) { etree *x; if(!isstackempty(sp->top)) { x = sp->ST[sp->top]; sp->top = sp->top - 1; return(x); } else return(NULL); } etree *getnode(char d) { etree *node; node = (etree *)malloc(sizeof(etree)); node->lc = NULL; node->data = d; node->rc = NULL; return(node); } etree *construct_etree_from_postfix_exp(char pos[]) { int i; stack s; etree *root = NULL,*node; initialize_stack(&s); for(i=0;pos[i] != '\0';i++) { node = getnode(pos[i]); if(isalpha(pos[i])) { push(&s,node); } else //operator { node->rc = pop(&s); node->lc = pop(&s); push(&s,node); } } root = pop(&s); return(root); } void inorder(etree *temp) { if(temp!= NULL) { inorder(temp->lc); printf("%c",temp->data); inorder(temp->rc); } } void preorder(etree *temp) { if(temp!= NULL) { printf("%c",temp->data); preorder(temp->lc); preorder(temp->rc); } } void postorder(etree *temp) { if(temp!= NULL) { postorder(temp->lc); postorder(temp->rc); printf("%c",temp->data); } } void inorder_nonrec(etree *root) { stack s; etree *temp; temp = root; initialize_stack(&s); while(temp!=NULL s.top!= -1) { while(temp!=NULL) { push(&s,temp); temp = temp->lc; } temp = pop(&s); printf("%c",temp->data); temp = temp->rc; } } void preorder_nonrec(etree *root) { stack s; etree *temp; temp = root; initialize_stack(&s); while(temp!=NULL s.top!= -1) { while(temp!=NULL) { printf("%c",temp->data); push(&s,temp); temp = temp->lc; } temp = pop(&s); temp = temp->rc; } } void postorder_nonrec(etree *root) { stack s; etree *temp; int i,k=0; char A[30]; temp = root; initialize_stack(&s); while(temp!=NULL s.top!= -1) { while(temp!=NULL) { A[k++] = temp->data; push(&s,temp); temp = temp->rc; } temp = pop(&s); temp = temp->lc; } for(i=k-1;i>=0;i--) { printf("%c",A[i]); } } void main() { char pos[30]; etree *root = NULL; int ch; do { clrscr(); printf("\n Choice 1: Create Etree from postfix expression "); printf("\n Choice 2: Recursive inorder,preorder & postorder traversal"); printf("\n Choice 3: Nonrecursive inorder,preorder & postorder traversal"); printf("\n Choice 4: exit "); printf("\n Enter your choice: "); scanf("%d",&ch); switch(ch) { case 1: printf("\n\nEnter the postfix expression : "); scanf("%s",pos); root = construct_etree_from_postfix_exp(pos); printf("\n\nExpression tree created successfully !!"); break; case 2: printf("\n Inorder traversal is : "); inorder(root); printf("\n preorder traversal is : "); preorder(root); printf("\n postorder traversal is : "); postorder(root); getch(); break; case 3: printf("\n Inorder traversal (nonrecursive) : "); inorder_nonrec(root); printf("\n Preorder traversal (nonrecursive) : "); preorder_nonrec(root); printf("\n Postorder traversal (nonrecursive) : "); postorder_nonrec(root); getch(); break; case 4: printf("\n \t**End of program** \n \t\tThank you\n"); break; default:printf("\n invalid choice try again!!!!"); } getch(); }while(ch!=4); } Written by: Fabianski Benjamin


Why didn't i get the preorder bonus from gamestop for nfs the run?

I'm afraid the only people likely to be able to answer that are Gamestop themselves. I suggest you return to the shop you purchased it from with proof-of-purchase (the receipt).


Did World War 2 play a role in the cause of the Vietnam war?

Yes. Japan's surrender during WWII, also resulted in Japan's departure from occupied territories, of which Vietnam was one. Which resulted in the return of the French, which resulted in a confrontation-which was the French Indochina War 1946-1954.


Can you trade in pre order?

If you cancel a preorder you should be able to receive a refund unless you also got something at the time of the preorder as a bonus. Trade in is never without a cost and reduction of the original purchase price and is not the same as an exchange for credit or cash where you receive you original purchase price at most retail outlets. Some carry cancellation or return charges that are also called restocking fees


What contributed to the long postwar economic boom was it the continued exclusion of most women from the workplace?

No....resulted from the return home of all overseas military


Why was there a baby boom?

In the US the "baby boom" resulted from the return of many soldiers from WW2 and getting married. This period lasted from 1945 into the early 1960s.


If you trade in games at GAME would you get money off the New call of duty if you pre order it?

Normally you would be able to trade in toward a reduction in the price of the new preorder, but the latest expected Call of Duty release will not be not available for preorder for some months. You could get a reduced price on Call of Duty Black Ops Selling your games at a site like Glyde or Ebay would give a greater return on popular wanted games and unwanted games would not have a trade in value anyway