0

According to Wikipedia, an important choice when making a suffix tree implementation is the parent-child relationships between nodes. The most common one is using linked lists called sibling lists.

How does this work in Java?

jogojapan
  • 68,383
  • 11
  • 101
  • 131

2 Answers2

2

In a sibling list, each node has exactly two references: first-child and next-sibling. This lets you iterate over all the children of a node by starting with first-child, and then following next-sibling until you get to the child whose next-sibling is null. I don't see why Java would be any different from any other programming language.

It's interesting to note that this representation is virtually identical to the standard representation of a binary tree, where left is spelled first-child and right is spelled next-sibling. This demonstrates the 1-1 relationship between binary trees and general trees with the same number of nodes. (It might seem contradictory at first, but note that a binary tree may have only a left child, or only a right child, and those are considered different. By contrast, in a general tree, there is only one way for a node to have one child.

rici
  • 234,347
  • 28
  • 237
  • 341
-1

Parent has a list of child nodes (either as array, double linked list or so) Each child has a link to its parent. Traversing is extremely simple as you don't need a stack.

alzaimar
  • 4,572
  • 1
  • 16
  • 30
  • Thanks for the downvote. What do you expect? It works the same way as it works for all programming languages. – alzaimar Nov 22 '12 at 23:08