Click to See Complete Forum and Search --> : One Parent node & multiple child nodes ??


Sriya
January 5th, 2007, 06:24 AM
Hi all...

In a binary tree.. we have one parent node and two Child node, right child and the left child. Do we have a possibility for a datastucture that has one parent node and variable number of child nodes, instead of just two as in case of a binary tree??

Simple put... is it possible to have one Parent node and 'n' child nodes??

Pls help me in this.

Thank you all!!

Sriya!

Gluon
January 20th, 2007, 04:30 PM
Sure, everything is possible :)

I'm not sure if you prefer a specific programming language...
In object oriented programming you would probably have some sort of struct / class representing a node with one pointer to the parent and an array or something similar containing n pointers to the node's n child nodes. n is called the degree of the node. A tree consisting of nodes with degree n is an n-ary tree.