Skip to content

This repository contains code for finding the Lowest Common Ancestor (LCA) and Lowest Dominating Common Ancestors (LDCAs) in an n-ary tree.

License

Notifications You must be signed in to change notification settings

HMWCS/java-nary-tree-lca-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

N-ary Tree LCA & LDCA Finder

This repository contains code for finding the Lowest Common Ancestor (LCA) and Lowest Dominating Common Ancestors (LDCAs) in an n-ary tree.

Definitions

  • LCA (Lowest Common Ancestor): The single, deepest shared parent for a given set of nodes in a tree.
  • LDCAs (Lowest Dominating Common Ancestors): Multiple nodes forming the deepest set that dominates the paths to the nodes in a given descendant set, ensuring all routes to these descendants pass through this node set.

Usage

  • LCA: Use NaryTreeLCAFinder.findLCA(TreeNode root, Set<TreeNode> nodes) to find the lowest common ancestor of the given nodes.
  • LDCAs: Use NaryTreeLCAFinder.findLDCAs(TreeNode root, Set<TreeNode> nodes) to find the lowest dominating common ancestors of the given nodes.

About

This repository contains code for finding the Lowest Common Ancestor (LCA) and Lowest Dominating Common Ancestors (LDCAs) in an n-ary tree.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages