Back to problems

Determine Whether Two Horses Are Related (Pedigree Graph)

Algorithm · Google · Medium

Problem: Determine Whether Two Horses Are Related (Pedigree/Ancestry) Given a collection of pedigree links and two horses, a and b, decide whether the two horses have a biological relationship. Definition Every link represents a directed ancestry relationship in the form parent -> child. Treat a and b as related when at least one of these conditions is true: One horse is an ancestor of the other; or The horses have one or more common ancestors, meaning their ancestor sets…

Checking your access…