Folowing program construct tree structure. Draw the constructed tree, and list the output of the given program. #include struct nodetype { struct nodetype char info; *left; struct nodetype *right; }; typedef struct nodetype *NODEPTR; void xtrav(NODEPTR); NODEPTR maketree(int); void main() { NODEPTR root, p, q; root = NULL; char sevenChar[7] = { E, 'A','B',L, 'C','D',M }; char ch; int i = 0; sevenChar[i]; maketree(ch); /* insert first root item */ ch = root = do { ch = sevenChar[++i]; p = q = root; /* find insertion point */ while (q != NULL) { Tree structure p = q; if (ch > p->info) q = p->left; else q = p->right; } maketree(ch); /* insertion */ if (ch > p->info) p->left 9 = = q; else p->right = q; } while (i != 6); printf("X Traversing\n"); Output of the Program xtrav(root); void xtrav(NODEPTR tree) { if (tree != NULL) { xtrav(tree->left); xtrav(tree->right); printf("%c\n", tree->info); } } NODEPTR maketree(int x) { NODEPTR p; p = (NODEPTR) malloc (sizeof (struct nodetype)); p->info = x; p->left = NULL; p->right = NULL; return(p); Page 3 of 5
Folowing program construct tree structure. Draw the constructed tree, and list the output of the given program. #include struct nodetype { struct nodetype char info; *left; struct nodetype *right; }; typedef struct nodetype *NODEPTR; void xtrav(NODEPTR); NODEPTR maketree(int); void main() { NODEPTR root, p, q; root = NULL; char sevenChar[7] = { E, 'A','B',L, 'C','D',M }; char ch; int i = 0; sevenChar[i]; maketree(ch); /* insert first root item */ ch = root = do { ch = sevenChar[++i]; p = q = root; /* find insertion point */ while (q != NULL) { Tree structure p = q; if (ch > p->info) q = p->left; else q = p->right; } maketree(ch); /* insertion */ if (ch > p->info) p->left 9 = = q; else p->right = q; } while (i != 6); printf("X Traversing\n"); Output of the Program xtrav(root); void xtrav(NODEPTR tree) { if (tree != NULL) { xtrav(tree->left); xtrav(tree->right); printf("%c\n", tree->info); } } NODEPTR maketree(int x) { NODEPTR p; p = (NODEPTR) malloc (sizeof (struct nodetype)); p->info = x; p->left = NULL; p->right = NULL; return(p); Page 3 of 5
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY