Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Construct a binary tree of lists, e.g. each node contains its own list of conten

ID: 3692798 • Letter: C

Question

Construct a binary tree of lists, e.g. each node contains its own list of contents. Data is constructed in pairs of chars, ex: ( A, E) the character A would be in the node A, but character E is added to the list inside of A. Create a driver that creates data pairs, populates the structure, and then displays the contents. (A depth first search is recommended). Can anybody help me write a C++ code for the question above? Construct a binary tree of lists, e.g. each node contains its own list of contents. Data is constructed in pairs of chars, ex: ( A, E) the character A would be in the node A, but character E is added to the list inside of A. Create a driver that creates data pairs, populates the structure, and then displays the contents. (A depth first search is recommended). Can anybody help me write a C++ code for the question above? Construct a binary tree of lists, e.g. each node contains its own list of contents. Data is constructed in pairs of chars, ex: ( A, E) the character A would be in the node A, but character E is added to the list inside of A. Create a driver that creates data pairs, populates the structure, and then displays the contents. (A depth first search is recommended). Can anybody help me write a C++ code for the question above? Construct a binary tree of lists, e.g. each node contains its own list of contents. Data is constructed in pairs of chars, ex: ( A, E) the character A would be in the node A, but character E is added to the list inside of A. Create a driver that creates data pairs, populates the structure, and then displays the contents. (A depth first search is recommended). Can anybody help me write a C++ code for the question above?

Explanation / Answer

typedef struct BST {
char data;
struct BST *lchild, *rchild;
} node;

void insert(node *root, node *A) {
if (A->data < root->data) {
if (root->lchild == NULL)
root->lchild = A;
else
insert(root->lchild, A);
}

if (A -> root->data) {
if (root->rchild == NULL)
root->rchild = A;
else
insert(root->rchild, A);
}
}


void InsertNode(Node*& root, Node* node)
{
if (root == 0)
root = node;
else if (root->value < node->value)
InsertNode(root->left, node);
else
InsertNode(root->right, node);
}


}

node *new_node, *root;

char main()
{
A = get_node();
printf(" Enter The Element ");
scanf("%d", &A->data);

if (root == NULL) /* Tree is not Created */
root = A;
else
insert(root, A)
}