Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3662932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:28:22+00:00 2026-05-19T01:28:22+00:00

I have built a family tree program which thus far allows you to add

  • 0

I have built a family tree program which thus far allows you to add relationships to nodes (mother, father, partner & siblings). This allows the tree to be built. well at least the links to be made.

My problem is I have to represent the tree textually. This is proving to be very hard. I thought of allowing to display the ancestors and descendants for a particular node but this proves to be difficult, especially when there are more than two generations for displaying ancestors (great grandparents and above).

To make things more clear I thought of using a file tree structure but got into a mess when displaying for great grandparents.

I can provide the source if anyone wants to see it.


What I mean is using a file structure starts of with a pair of people:
e.g.

GRANDAD & GRANDMA
—DAD

——ME
——SISTER
—AUNT

——COUSIN
——COUSIN

This would be for showing my ancestors on my dads side (inclusive of me). My question is what happens if both my grandparents have parents? How would I represent such relationships with the above structure? I would have to show my great grand-parents but there would be two sets! One for my grandma and one for my grandad. The root has been split into two if you see what I mean….

I though about limiting the ‘show ancestors’ function to show only 2 generations above. Which means that a user can traverse through the tree and indentify his/her great grandparents by selecting their parent nodes and displaying their ancestors – but this seems laborious and not very intuitive.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:28:23+00:00Added an answer on May 19, 2026 at 1:28 am

    The following method may do what you want. It will print a tree in a tabbed hierarchical structure:

    public void printTree(Node root, int tabLevel, PrintStream out){
        for(int i =0;i < tabLevel; i++) out.print("\t");
        out.println(root)
        for(Node n: root.getChildren())
            printTree(n, tabLevel + 1, out);
    }
    

    You would call it like so:

    printTree(rootNode, 0, System.out);
    

    This doesn’t take into account all of the the complexities of a family tree, but it should provide a good place to start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.