Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C# 4.0

A Link to LINQ and a Look at the Binary Search Tree

Rate me:
Please Sign up or sign in to vote.
4.43/5 (7 votes)
19 Apr 2010CPOL6 min read 33.6K   200   18  
A Comprehensive Look at LINQ and the Binary Search Tree Data Structure
using System;
using BinaryTreeLibrary;

public class TreeTest
{
    public static void Main(string[] args)
    {
        Tree tree = new Tree();
        int insertValue;

        Console.WriteLine("Inserting Values:  ");
        Random random = new Random();
        for (int i = 1; i <= 10; i++)
        {
            insertValue = random.Next(100);
            Console.Write(insertValue + " ");
            tree.insertNode(insertValue);
        }

        Console.WriteLine("\n\nPreorder traversal");
        tree.PreorderTraversal();

        Console.WriteLine("\n\nInorder traversal");
        tree.InorderTraversal();

        Console.WriteLine("\n\nPostorder traversal");
        tree.PostorderTraversal();
        Console.WriteLine();
    }
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Monroe Community
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions