Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Find lowest common ancestor in a in a tree using the Adjacency list model

Find lowest common ancestor in a in a tree using the Adjacency list model

Scheduled Pinned Locked Moved Database
data-structureshelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jorgen Andersson
    wrote on last edited by
    #1

    I'm having a tree structure using the Adjacency list model, having an ID and ParentID for every node in the tree. I need to find the lowest common ancestor for two or more IDs. Anyone that knows how to do this? (I know how to do it with the path enumeration or nested set model, but that doesn't help me here)

    M 1 Reply Last reply
    0
    • J Jorgen Andersson

      I'm having a tree structure using the Adjacency list model, having an ID and ParentID for every node in the tree. I need to find the lowest common ancestor for two or more IDs. Anyone that knows how to do this? (I know how to do it with the path enumeration or nested set model, but that doesn't help me here)

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Jörgen Andersson wrote:

      using the Adjacency list model

      I'm curious, what is this? What database are you using? Does this model dictate the format of your keys? I use the hierarchyid in SQL Server to store my structures. How you would achieve this is dependant on your data structure.

      Never underestimate the power of human stupidity RAH

      J 1 Reply Last reply
      0
      • M Mycroft Holmes

        Jörgen Andersson wrote:

        using the Adjacency list model

        I'm curious, what is this? What database are you using? Does this model dictate the format of your keys? I use the hierarchyid in SQL Server to store my structures. How you would achieve this is dependant on your data structure.

        Never underestimate the power of human stupidity RAH

        J Offline
        J Offline
        Jorgen Andersson
        wrote on last edited by
        #3

        Adjacency_list[^] is what Joe Celko calls what probably is the most common representation of a tree in a database. Where every node has an ID and also stores the id of its parent. I'm using Oracle

        M 1 Reply Last reply
        0
        • J Jorgen Andersson

          Adjacency_list[^] is what Joe Celko calls what probably is the most common representation of a tree in a database. Where every node has an ID and also stores the id of its parent. I'm using Oracle

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Thank you, I'm sorry not to be able to help, I have not used Oracle in a decade or so.

          Never underestimate the power of human stupidity RAH

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups