Share
Explore BrainMass

Binary Trees: Family tree of two generations

Create a program that uses the structure of binary trees to make a family tree of two generations. The user should input the names when asked, and then the program should display the names.

Please see the attached Image1.jpg on how the program should store its data.

Attachments

Solution Preview

#include < unistd.h >
#include < iostream >
#include < string >

using namespace std;

// User (1) + Parents (2) + GrandParents (4) = 7
string twoGenerations[7];

int main()
{
cout << "User Name : ";
getline(cin,twoGenerations[0]);

cout << "Father's Name : ";
getline(cin,twoGenerations[1]);

cout << "Mother's Name : ";
...

Solution Summary

Solution maintains the binary tree in an array. Comments in the code explain how to access the parent nodes of a tree node in this organization. It is also available as an attachment 129367.cpp that can be compiled using "g++ 129367.cpp".

$2.19