Skip to content

LCA implementation for Binary Tree#3138

Open
Vanshraj30 wants to merge 4 commits into
TheAlgorithms:masterfrom
Vanshraj30:LCA-trees
Open

LCA implementation for Binary Tree#3138
Vanshraj30 wants to merge 4 commits into
TheAlgorithms:masterfrom
Vanshraj30:LCA-trees

Conversation

@Vanshraj30
Copy link
Copy Markdown

Description

Added a C++ implementation of the Lowest Common Ancestor (LCA) algorithm for a Binary Tree.

Changes Made

  • Implemented LCA using a recursive approach
  • Handled edge cases where one or both nodes may not exist
  • Added clean and readable code structure

Purpose

This implementation helps in understanding tree-based algorithms and is useful for solving problems involving hierarchical relationships in binary trees.

Complexity

  • Time Complexity: O(n)
  • Space Complexity: O(h)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant