Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save paratechnical/f63009442e02ffe62e20b922bdb9237a to your computer and use it in GitHub Desktop.

Select an option

Save paratechnical/f63009442e02ffe62e20b922bdb9237a to your computer and use it in GitHub Desktop.
C# Prefix Tree Node
class Node
{
public char Char;
public bool AWordEndsHere;
public List<Node> Subtree;
public Node(char c)
{
Char = c;
Subtree = new List<Node>();
}
public Node(char c, bool wordends):this(c)
{
AWordEndsHere = wordends;
}
public Node GetChild(char c)
{
if (Subtree.Count != 0)
foreach (var node in Subtree)
if (node.Char == c)
return node;
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment