Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

node with more than 3 leaf  RSS feed

 
sudharshiya mohan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want i create a node with 4 or more leaf as shown below
O ---------O
/ \ / \ / \ / \
O O O O O O O O
anyone help me please
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but your question is much too vague. What kind of node do you want to create? Are you writing your own classes to represent a tree structure? Do you understand how to create a node with 3 or less leaves? So why is creating a node with more than 3 leaves difficult? What does your source code look like?
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds like you want to build a tree ?
the parent needs to have a datastructure that holds all the child nodes (e.g. a Set)
then in your (parent) node you need a method like addChild(SomeObject obj) which adds the object to the datastructure.
also you will need methods to retrieve the childreen and so on...

k
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!