void treeprint(struct tnode *p) { if (p != NULL) { treeprint(p->left); printf("%d: %d\n", p->val, p->count); treeprint(p->right); } }
int main(int argc, char *argv[]) { struct node *root = NULL; root = insert(root, 12); root = insert(root, 54); root = insert(root, 8); root = insert(root, 33); treeprint(root); printf("\n"); root = insert(root, 25); treeprint(root); printf("\n"); root = insert(root, 1); treeprint(root); printf("\n"); root = insert(root, 11); treeprint(root); printf("\n"); root = insert(root, 17); /* root = newnode(7); root->left = newnode(4); root->right = newnode(8); root->left->right = newnode(6); root->left->left = newnode(3); */ return 0; }
/* word frequency count */ int main() { struct tnode *root, *freqroot; char word[MAXWORD]; char *key[MAXKEYLIST]={NULL,}; root = NULL; freqroot = NULL; // 새로운 트리를 위한 뿌리 노드를 만들어야 한다. while (getword(word, MAXWORD) != EOF) if (isalpha(word[0])) root = addtree(root, word); freqroot = createtreefromtree(root, freqroot); treeprint(root); printf("==END::raw tree==\n"); treeprint2(freqroot); printf("==END::freq tree==\n"); inorder_traversal(root,key); int ti=0; while(key[ti]!=NULL){ //if(ti<10){ root=reducetree(root,key[ti++]); //} //printf("%s\n",key[ti++]); } //printf("end key list\n"); treeprint(root); printf("finish print\n"); return 0; }
int treeprint(struct tree *t, int depth) { if (t!=NULL) { int i=0; fflush(stdout); /**/ if(t->nkids==1) { for(i=0; i<t->nkids; i++) { treeprint(t->kids[i], depth); } }/**/ else { if (depth != 0) { printf("%*s", depth*2, " "); fflush(stdout); } printf(" %d-%s: ",t->prodrule, rulename(t->prodrule)); fflush(stdout); if (t->nkids==0) { printf("Leaf: %s\n", t->leaf->text); } else { printf("%d\n", t->nkids); fflush(stdout); for(i=0; i<t->nkids; i++) { treeprint(t->kids[i], depth+1); } } } } }
//treeprint函数:按序打印树p void treeprint(struct tnode *p){ if(p){ treeprint(p->left); printf("%4d %s\n", p->count, p->word); treeprint(p->right); } }
/* treeprint */ void treeprint(struct tnode *p) { if (p != NULL) { treeprint(p->left); printf("%s \t%4d\n", p->word, p->count); treeprint(p->right); } }
/* treeprint: in-order print of tree p */ void treeprint(WordNode *p) { if (p != NULL) { treeprint(p->left); printf("%d %s\n", p->count, p->word); treeprint(p->right); } }
void treeprint(struct tnode *p) //Inorder traversal { if (p != NULL) { treeprint(p->left); printf("%4d %s\n", p->count, p->word); treeprint(p->right); } }
void treeprint(struct tnode *p) { if(p != NULL) { treeprint(p->left); if(p->match) printf("%s\n", p->word); treeprint(p->right); } }
void treeprint(struct tnode *p) { if (p == NULL) return; treeprint(p->left); printf("%s\n", p->word); treeprint(p->right); }
void treeprint(struct treenode *node){ if(node != NULL){ treeprint(node->left); printf("%4d %s\n", node->count, node->word); treeprint(node->right); } }
void treeprint2(struct tnode *p) { if (p != NULL) { treeprint(p->left); if(p->count > 1) printf("%4d %s\n", p->count, p->word); treeprint(p->right); } }
/* treeprint: in-order print of tree p */ static void treeprint(struct tnode *p) { if (p != NULL) { treeprint(p->left); if (binsearch(p->word, keywords, NKEYS) < 0) printf("%4d %s\n", p->count, p->word); treeprint(p->right); } }
/* treeprint: in-order print of tree p */ void treeprint(struct tnode *p) { if (p != NULL) { treeprint(p->left); printf("%s (", p->word); dia_print(p->ref); printf(")\n"); treeprint(p->right); } }
void treeprint(struct tnode *p){ if(p != NULL){ treeprint(p->left); printf("%s %d: %d", p->word, p->count, p->lines[0]); int i; for(i=1; i<=p->indLastoccurence; i++) printf(", %d", p->lines[i]); printf("\n"); treeprint(p->right); } }
void treeprint(struct tnode *p) { if (p != NULL) { treeprint(p->left); printf("%s\n\t", p->word); p->firstline = deleteline(p->firstline); for (struct linelist *pl = p->firstline; pl != NULL; pl = pl->next) printf("%d ", pl->line); printf("\n\n"); treeprint(p->right); } }
void treeprint(struct node *root) { struct node *current = root; if(current == NULL){ return ; } else { printf("%d ", current->data); treeprint(current->left); treeprint(current->right); } }
void treeprint(struct word *p) { int *t; if(p!=NULL){ treeprint(p->left); printf("%s %4d:",p->w,p->count); for(t=p->location;t<p->location+count;p++) printf("%4d\t",*t); printf("\n"); treeprint(p->right); } }
/* * Prints all values of the tree in order, using depth-first traversal. */ void treeprint(node * root) { if (root->left != NULL) treeprint(root->left); printf("ldata: %f\n", root->ldata); if (root->middle != NULL) treeprint(root->middle); if (root->is3node) { printf("rdata: %f\n", root->rdata); } if (root->right != NULL) treeprint(root->right); }
void treeprint(struct node *p) { struct line_node *line; if (p != NULL) { treeprint(p->left); printf("%s", p->word); for (line = p->lines; line != NULL; line = line->next) printf(" %d", line->num); printf("\n"); treeprint(p->right); } }
/* treeprint: in-order print of tree p */ void treeprint(struct tnode *p) { struct tlinen *nln; if (p != NULL) { treeprint(p->left); printf("%s: ", p->word); for (nln = p->linen; nln != NULL; nln = nln->next) printf("%d ", nln->line); printf("\n\n"); treeprint(p->right); } }
void treeprint(struct tnode *p) { int i = 0; if (p != NULL){ treeprint(p->left); printf("%4d %s occures in lines:", p->count, p->word); for (i = 0; i <= p->sp; i++){ printf("%d ", (p->line)[i]); } printf("\n"); treeprint(p->right); } }
/* treeprint: in-order print of tree p */ void treeprint(struct tnode *p) { struct tgroup *tmp_group; if (p != NULL) { treeprint(p->left); printf("Group %s:\t", p->stub); for (tmp_group = p->group; tmp_group != NULL; tmp_group = tmp_group->next) printf("%s ", tmp_group->word); printf("\n"); treeprint(p->right); } }
// treeprint: in-order print of tree root char *treeprint(struct tnode *root, char *s, int n) { char *t; if(root != NULL){ t = treeprint(root->left, s, n); if(t != NULL && strncmp(t, root->word, n) != 0) printf("\n"); printf("%s\n", root->word); return treeprint(root->right, root->word, n); } else { return s; } }
/* treeprint: in-order print of tree p */ void treeprint(struct tnode *p) { if (p != NULL) { treeprint(p->left); if (p->group) { if (lg != p->group) printf("------------------(%d)------------------\n", p->group); printf("\t%4d %s\n", p->count, p->word); lg = p->group; } treeprint(p->right); } }
int main(int argc, char *argv[]) { int maxword = 6; struct tnode *root, *dummy; char word[MAXWORD]; root = NULL; if (argc > 1) maxword = abs(atoi(argv[1])); while (getword(word, maxword) != EOF) if (strlen(word) == maxword && isalpha(word[0])) root = addtree(root, word); if ((argc > 2) && (strcmp(argv[2], "-d") == 0)) { dummy = talloc(); dummy->word = strdupl(""); dummy->count = 0; dummy->print = 0; dummy->left = dummy->right = NULL; while (printed < units) { d = dummy; treeprint(root, 1); printf("%4d %s\n", d->count, d->word); d->print = 1; printed++; } } else if ((argc > 2) && (strcmp(argv[2], "-r") == 0)) { dummy = talloc(); dummy->word = strdupl(""); dummy->count = 100; dummy->print = 0; dummy->left = dummy->right = NULL; while (printed < units) { d = dummy; treeprint(root, 2); printf("%4d %s\n", d->count, d->word); d->print = 1; printed++; } } else treeprint(root, 0); return 0; }
/* treeprint: in-order print of tree p */ void treeprint(struct tnode *p) { int i; if (p != NULL) { treeprint(p->left); printf("%4d %s\n", p->count, p->word); for (i = 0; i < MAXLINENUM; ++i) { if (p->line_nums[i] == 0) break; printf("\t%4d.%d\n", i+1, p->line_nums[i]); } treeprint(p->right); } }
void treeprint(struct tnode *t, int n) { if (t == NULL) { return; } else { treeprint(t->left, n); if (strncmp(t->value, prefix, n) == 0) { printf("%s\n", t->value); } else { printf("---\n%s\n", t->value); strncpy(prefix, t->value, n); } treeprint(t->right, n); } }
/* treeprint: in-order print of tree p */ void treeprint(struct tnode *p) { if (p != NULL) { treeprint(p->left); printf("Word: %-15sTotal: %i\n", p->word, p->count); printf(" Appears on: "); int i; for (i = 0; i < p->count; ++i) printf("%i ", p->linenum[i]); printf("\n"); treeprint(p->right); } }
void treeprint(struct tnode* p) { int i; if(p!=NULL) { treeprint(p->left); printf("%d %s:\n", p->count, p->word); for(i=1; i<=p->count; i++) { printf("Line %d\n", p->linenum[i]); } treeprint(p->right); } }