Help regarding QTree2

Revision en1, by retr0coderxyz, 2020-03-21 14:53:09

Hey guys!

I am trying to solve Qtree2 from SPOJ after learning about LCA using binary lifting.Problem

There are 2 parts to this question one is to find distance between any two given nodes and the other part is to find kth node in the path between 2 nodes.

While I was able to solve the first part, but I am stuck in solving second part, I tried a lot (only clue i was able to find out is that the path goes through LCA of two nodes) and couldn't proceed from there.

It would be really helpful if someone could give a detailed explanation using binary lifting it would be great. Thank you so much!

Tags #spoj, #binary-lifting, lca

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English retr0coderxyz 2020-03-21 14:53:09 671 Initial revision (published)