×
Home Discussions Write at Opengenus IQ
×
  • Track your progress
  • RANDOM
  • Join our Internship ๐ŸŽ“
  • 100+ Graph Algorithms
  • 100+ DP Problems
  • 50+ Linked List Problems
  • 50+ Array Problems
  • One Liner
  • 50+ Binary Tree problems
  • #7daysOfCode
  • Linux ๐Ÿ’ฝ
  • ๐Ÿ”Š Data Structures
  • Graph Algorithms
  • Dynamic Programming ๐Ÿ’‘
  • Home

lowest common ancestor

A collection of 2 posts

Algorithms

Using Farach Colton and Bender Algorithm to solve LCAใ€O(V) queryใ€‘

The basic idea of Farach Colton and Bender Algorithm is to traverse all the nodes using the Depth First Search graph traversal and keep a record of all the visited nodes and there corresponding heights. This allows to answer LCA queries in O(V) time complexity

Siddharth Agarwal Siddharth Agarwal
Algorithms

Binary Lifting with k-th ancestor and lowest common ancestor (LCA)

Binary Lifting is a technique used to find the k-th ancestor of any node in a tree in O(log N). This also leads to a faster algorithm in finding the lowest common ancestor (LCA) between two nodes in a tree. The technique requires preprocessing the tree in O(N log N) using dynamic programming.

Arshad G
OpenGenus IQ © 2022 All rights reserved โ„ข [email: team@opengenus.org]
Top Posts LinkedIn Twitter