Finding loop in a binary tree

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • babai678
    New Member
    • Oct 2007
    • 5

    #1

    Finding loop in a binary tree

    Hi all,

    I was wondering if someone can help me out in how to find a loop ( if at all it is there ) in a binary tree.

    Bibaswan
  • MarshMallow
    New Member
    • Nov 2007
    • 52

    #2
    I suggest to use a Depth First Visit algorithm

    Comment

    • babai678
      New Member
      • Oct 2007
      • 5

      #3
      Hi,

      Even if i use depth first , how i'll come to know whether there is a loop or not?
      And
      If there is a loop where is it?

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Go though the tree and keep track of the addresses you visit. If you visit the same address twice you have your loop.

        You can create a tree for the addresses visited or use a linked list.

        Comment

        Working...