Question: This is a binary tree for the family tree .I already did it for me, parents and grandparents. I need the Consanguinity Chart applied to

This is a binary tree for the family tree .I already did it for me, parents and grandparents. I need the Consanguinity Chart applied to my code.

package com.src;

class Node

{

String name;

Node left, right;

public Node(String item)

{

name = item;

left = right = null;

}

}

class BinaryTree

{

// Root of Binary Tree

Node root;

BinaryTree()

{

root = null;

}

void printLevelOrderFamily()

{

int h = height(root);

int i;

for (i=1; i

System.out.print("Generation level: "+ i + " -> ");

printGivenLevel(root, i);

System.out.println();

}

}

/* Compute the "height" of a tree .*/

int height(Node root)

{

if (root == null)

return 0;

else

{

/* compute height of each subtree */

int lheight = height(root.left);

int rheight = height(root.right);

/* use the larger one */

if (lheight > rheight)

return(lheight+1);

else return(rheight+1);

}

}

/* Print nodes at the given level */

void printGivenLevel (Node root ,int level)

{

if (root == null)

return;

if (level == 1)

System.out.print(root.name + " ");

else if (level > 1)

{

printGivenLevel(root.left, level-1);

printGivenLevel(root.right, level-1);

}

}

// Driver method

public static void main(String[] args)

{

BinaryTree tree = new BinaryTree();

tree.root = new Node("Myself");

tree.root.left = new Node("father P1");

tree.root.right = new Node("Mother P2");

tree.root.left.left = new Node("Grand Father P1-1");

tree.root.left.right = new Node("Grand Mother P1-2");

tree.root.right.left = new Node("Grand Father P2-1");

tree.root.right.right = new Node("Grand Mother P2-2");

System.out.println("Generation level Family tree is ");

tree.printLevelOrderFamily();

}

}

//output:

 This is a binary tree for the family tree .I already

I need this chart applied to the code Please!!!! :C

did it for me, parents and grandparents. I need the Consanguinity Chart

DBinaryTree.java 3 56 58 59 60 if (rootnul1) if (level-= 1) else if (level > 1) return; System.out.print(root.name ""); printGivenLevel (root.left, level-1); 62 63 64 65 printGivenLevel (root.right, level-1); 67 68 69 70 public static void main(Stringl] args) 71 72 73 74 75 76 // Driver method BinaryTree treenew BinaryTree) tree.root -new Node("Hyself"): tree.root.leftnew Node("father P1") tree.root.right new Node("Mother P2"); tree.root.left.left new Node("Grand Father P1-1"); tree.root.left.right - new Node("Grand Mother P1-2"); tree.root.right.left-new Node("Grand Father P2-1"); tree.root.right.right - new Node("Grand Mother P2-2") 78 79 Problems @ Javadoc Declaration ConsoleProgress Kterminated> Binary Tree [Java Application] C Program Files Javatire 1.8.0 16 bin javaw.exe (May 2, 2018, 11:15:15 AM Generation level Family tree is Generation level: 1 -> Myself Generation level: 2 -> father P1 Mother P2 Generation level: 3 - Grand Father P1-1 Grand Mother P1-2 Grand Father P2-1 Grand Mother P2-2 DBinaryTree.java 3 56 58 59 60 if (rootnul1) if (level-= 1) else if (level > 1) return; System.out.print(root.name ""); printGivenLevel (root.left, level-1); 62 63 64 65 printGivenLevel (root.right, level-1); 67 68 69 70 public static void main(Stringl] args) 71 72 73 74 75 76 // Driver method BinaryTree treenew BinaryTree) tree.root -new Node("Hyself"): tree.root.leftnew Node("father P1") tree.root.right new Node("Mother P2"); tree.root.left.left new Node("Grand Father P1-1"); tree.root.left.right - new Node("Grand Mother P1-2"); tree.root.right.left-new Node("Grand Father P2-1"); tree.root.right.right - new Node("Grand Mother P2-2") 78 79 Problems @ Javadoc Declaration ConsoleProgress Kterminated> Binary Tree [Java Application] C Program Files Javatire 1.8.0 16 bin javaw.exe (May 2, 2018, 11:15:15 AM Generation level Family tree is Generation level: 1 -> Myself Generation level: 2 -> father P1 Mother P2 Generation level: 3 - Grand Father P1-1 Grand Mother P1-2 Grand Father P2-1 Grand Mother P2-2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!