Skip to content

Tag: tree

Parent-Child Tree in Java

I was trying to implement a class Node to build a tree of Nodes. Basically, each Node can have children, so if I specify multiple nodes I can build a tree out of it. As an example: The problem I am having problems to solve is to build this tree and find all children of a given element (in this

Checking a tree to be a BST

Here is my attempt to check whether a tree is a BST or not: Code works fine as tested with multiple test cases. But I am not sure if this is a good, clean approach. Recursive method is big it seems. I am dealing with scenarios like null left node, null right node, node itself null, both child nodes null

Flat tree of objects while keeping father and child

I have a class Employee which has a tree structure with property team Using Java lambdas I need to flat this tree into same level list while converting Employee class into the following ConvertedEmployee while storing names in dedicated lead and subordinates properties. So ConvertedEmployee is in some sense a…