plz can any one to tell me how to make 5+3*4/2 in a binary search tree in c (with code)
plz can any one to tell me how to make 5+3*4/2 in a binary search tree in c (with code)
Last edited by Radwa; 05-11-2013 at 05:12 PM.
What do you understand by "make 5+3*4/2 in a binary search tree"? I mean, it sounds like you want a syntax tree instead.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
i want to understand how i can do it
You mean you want us to provide the code for you?in c (with code)
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
yes plz
what are the terms of the contract?
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
What does this mean؟
plz can anyone to help me i need it too much
No. The "Give meh da codez" approach does not work here.
We have zero interest in simply doing your work for you.
You will get nothing from us without posting a serious attempt at this.
Edit: Actually I take that back, make it "... get nothing positive without ..."; you may of course receive some negative comments.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
plz can anyone to help me i need it too much
Code:#include <stdio.h> #include <stdlib.h> #include <math.h> typedef char EType; typedef struct tnode { EType data; char a[9]; struct tnode* left; struct tnode* right; }tnode; typedef struct tnode* BTREE; tnode* insertBST (BTREE T,char x) { int i; int a[i]; tnode* tmpcell; tmpcell=(tnode*)malloc(sizeof(tnode)); if(tmpcell==NULL) { printf("out of space"); return tmpcell; }else { tmpcell->data=x; tmpcell->left=tmpcell->right=NULL; } if(T==NULL) T=tmpcell; else if(x<T->data) T->left=insertBST(T->left,x); else if(x>T->data) T->right=insertBST(T->right,x); return T; } void show_node (BTREE T) { printf("%c\n",T->data); } int tree (char a[9]) {BTREE T; int i,x; for( i=0;i>9;i++){ a[i]=insertBST(T,x); return a[9]; } } void inorder (BTREE T) { if(T!= NULL) { inorder(T->left); show_node(T); inorder(T->right); } } void postorder (BTREE T) { if(T!= NULL) { postorder(T->left); postorder(T->right); show_node(T); } } void preorder (BTREE T) { if(T!=NULL) { show_node(T); preorder(T->left); preorder(T->right); } } int main (void) { char a[9]; BTREE T1,T2,T3,T4; T1=T2=T3=NULL; T1=insertBST(T1,1); T1=insertBST(T1,2); T1=insertBST(T1,0); T1=insertBST(T1,8); printf("\npreordar traverse\n"); preorder(T1); printf("\nPostorder Traverse:\n"); Postorder(T1); printf("\nInorder Traverse:\n"); Inorder(T1); }
You could start with correcting all the warnings/errors the compiler gives you:
You should also ask specific questions instead of dumping your code here and hoping that someone will rewrite it.Code:$ gcc -Wall -Wextra -lm foo.c foo.c: In function ‘insertBST’: foo.c:16:9: warning: unused variable ‘a’ [-Wunused-variable] foo.c: In function ‘tree’: foo.c:48:9: warning: assignment makes integer from pointer without a cast [enabled by default] foo.c: In function ‘main’: foo.c:94:5: warning: implicit declaration of function ‘Postorder’ [-Wimplicit-function-declaration] foo.c:96:5: warning: implicit declaration of function ‘Inorder’ [-Wimplicit-function-declaration] foo.c:85:20: warning: unused variable ‘T4’ [-Wunused-variable] foo.c:84:10: warning: unused variable ‘a’ [-Wunused-variable] foo.c:97:1: warning: control reaches end of non-void function [-Wreturn-type] foo.c: In function ‘tree’: foo.c:52:1: warning: control reaches end of non-void function [-Wreturn-type] foo.c: In function ‘insertBST’: foo.c:16:5: warning: ‘i’ is used uninitialised in this function [-Wuninitialized] foo.c: In function ‘tree’: foo.c:48:19: warning: ‘x’ may be used uninitialised in this function [-Wuninitialized] foo.c:48:19: warning: ‘T’ may be used uninitialised in this function [-Wuninitialized] /tmp/ccuRngGr.o: In function `main': foo.c:(.text+0x2c0): undefined reference to `Postorder' foo.c:(.text+0x2d8): undefined reference to `Inorder' collect2: ld returned 1 exit status
Bye, Andreas
I correct all errors but i can't connect array index to be a pointer to the data inside the node can any one to help me in this problem
Do you mean the element of the array to be a pointer to the data? I say this because you should know that the index of an array can only be a postive integer valuearray index to be a pointer to the data
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
imean to put data of the tree node in a array
hmmm - i cant see how you got to the code above and yet cannot tackle that problem? Anyway from what i can gather i think you need to declare an array of your nodes - that is to say, each element of your array will contain an instance of your tnode struct or whatever
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"