Click here to Skip to main content
11,493,391 members (69,547 online)
Click here to Skip to main content
Articles » Database » Database » Databases » Downloads
Add your own
alternative version

Optimizing building trees from a database

, 20 Jan 2005 76.5K 596 52
How a different way of looking at a problem can result in better performance.
using System;
using System.Collections;

namespace BuildingTrees
  // The TreeNode is the basic building block of the tree. It can represent a root node,
  // as well as a leaf node, or any node in between.
  public class TreeNode
    // Declarations
    private int id;               // The ID of the node
    private TreeNode parentNode;  // The parent node of the node
    private string text;          // The payload of the node
    private ArrayList childNodes; // Contains the childnodes of the node

    // Constructor
    public TreeNode(int id, TreeNode parentNode)
      // Initialize the FastTreeNode = id;
      this.parentNode = parentNode;
      this.text = "";
      childNodes = new ArrayList();

      // Check if a parent was supplied
      if (parentNode != null)
        //Yes, then let the parentnode know it has a new child

    // Properties
    public int ID
      get {return id;}

    public TreeNode ParentNode
      get {return parentNode;}
        parentNode = value;
        // Let the parent node know it has a new child, if possible, and if necessary
        if (parentNode != null && !parentNode.ChildNodes.Contains(this))

    public string Text
      get {return text;}
      set {text = value;}

    public ArrayList ChildNodes
      get {return childNodes;}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Software Developer
Netherlands Netherlands
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150520.1 | Last Updated 20 Jan 2005
Article Copyright 2005 by NielsHoldijk
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid