in DS
351 views
3 votes
3 votes

What would be an appropraite data structure to represent family hierarchy where each node is an individual and there in no requirement to keep "married to" relationship?

  1. Binary Tree
  2. n-ary Tree
  3. Graph
  4. Linked List
in DS
by
351 views

2 Comments

it's graph??
0
0
how it can be tree??
0
0

2 Answers

3 votes
3 votes
with binary tree is not possible . cause we cannot represent one hving more than two children.

with n tree not possible . we can not represent sibiling or other kind of relationship that creates cycle.

yes, with graph , it is possible. and it is aprropriate.

with cyclic doubly linked list , it is possible to implement but it takes lot of space for double pointers . it is not appropriate than graph .

so i will go with option c
edited by

4 Comments

sir if married to is present then tree cant do it i think. in that case we use graphs? bcoz wife belongs to some other family.
3
3
yes..
0
0
Sir still can’t understand how n-ary tree will be enough to show both siblings and parents relation simultaneously.

In the figures on Pinterest, either it is depicted as single child with all their parents (& no siblings are present), or both mother & father aren’t depicted as a node in tree can have only 1 parent
0
0
0 votes
0 votes

It is definitely n-ary tree.

Linked List can't represent someone having two children.

Binary tree can't represent someone having three children.

A graph can represent A's child to be the father of B if A and B are siblings. (Visualize it)

An n-ary tree would represent someone having  number of children, without disrupting the hierarchy.

Option B

Answer:

Related questions