Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "bintree.h"
- #include "stacka.h"
- static int *value;
- static int *left;
- static int *middle;
- static int *right;
- void SetBT(int* V,int* L,int* R){
- value=V;
- left=L;
- right=R;
- }
- void SetTT(int* V,int* L,int *M,int* R){
- //printf(" SetTT - DOPLNIT");
- value=V;
- left=L;
- middle=M;
- right=R;
- }
- void inorder(int root){
- if(left[root]!=0)inorder(left[root]);
- printf("%d ",value[root]);
- if(right[root]!=0)inorder(right[root]);
- }
- void preorder(int root){
- printf("%d ",value[root]);
- if(left[root]!=0)preorder(left[root]);
- if(right[root]!=0)preorder(right[root]);
- }
- void postorder(int root){
- if(left[root]!=0)postorder(left[root]);
- if(right[root]!=0)postorder(right[root]);
- printf("%d ",value[root]);
- }
- void levelorder(int root){
- printf("DOPLNIT");
- }
- void inorderNR(int v){
- Stack S;
- S = CreateStack( 12 );
- LT: while(left[v]!=0){
- Push(v,S);
- v=left[v];
- }
- NODE:printf("%d ",value[v]);
- if(right[v]!=0){
- v=right[v];
- goto LT;
- }
- if(!IsEmpty(S)){
- v=Top(S);
- Pop(S);
- goto NODE;
- }
- DisposeStack( S );
- }
- void preorderNR(int v){
- //printf("DOPLNIT");
- Stack S;
- S = CreateStack( 12 );
- }
- void preorderTT(int root){
- //printf("DOPLNIT");
- printf("%d ",value[root]);
- if(left[root]!=0)preorderTT(left[root]);
- if(middle[root]!=0)preorderTT(middle[root]);
- if(right[root]!=0)preorderTT(right[root]);
- }
- void postorderTT(int root){
- //printf("DOPLNIT");
- if(left[root]!=0)postorderTT(left[root]);
- if(middle[root]!=0)postorderTT(middle[root]);
- if(right[root]!=0)postorderTT(right[root]);
- printf("%d ",value[root]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement