本文整理汇总了C#中BinaryTree.PreorderTraversal方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryTree.PreorderTraversal方法的具体用法?C# BinaryTree.PreorderTraversal怎么用?C# BinaryTree.PreorderTraversal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryTree
的用法示例。
在下文中一共展示了BinaryTree.PreorderTraversal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
List list = new List();
list.Add("A");
list.Add("B");
list.Add("C");
list.Add("D");
list.Add("E");
list.Add("F");
list.Add("G");
list.Add("H");
list.ListNodes();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Deleting node 8");
list.Delete(8);
list.ListNodes();
Console.WriteLine();
Console.WriteLine("Position 5: " + list.Retrieve(5).NodeContent);
Console.WriteLine();
Console.WriteLine("Deleting node 5");
list.Delete(5);
Console.WriteLine();
Console.WriteLine("Position 5: " + list.Retrieve(5).NodeContent);
Console.WriteLine();
list.ListNodes();
Console.ReadLine();
//double linked list
DoubleLinkedList listdl = new DoubleLinkedList();
listdl.Insert("1");
listdl.Insert("2");
listdl.Insert("3");
DoubleLink link4 = listdl.Insert("4");
listdl.Insert("5");
Console.WriteLine("List: " + listdl);
listdl.InsertAfter(link4, "[4a]");
Console.WriteLine("List: " + listdl);
Console.Read();
link4 = listdl.Find ("[4a]");
listdl.Delete (link4);
Console.WriteLine ("List after delete:" + listdl);
listdl.Delete ();
Console.WriteLine ("list after delete first:" + listdl);
Console.Read ();
string str = "hello reverse words hello";
Console.WriteLine(str);
StringExamples mystring = new StringExamples();
Console.WriteLine(mystring.reverseWords(str));
Console.WriteLine("Reverse Recursively");
Console.WriteLine(mystring.reverseRecursively(str));
string str2 = "Reverse words in-place";
Console.WriteLine(str2);
Console.WriteLine(mystring.reverseWordsInPlace(str2));
string str3 = "remove whitespace\t\t\tin place";
Console.WriteLine(str3);
Console.WriteLine(mystring.removeWhitespaceInplace(str3));
string str4 = "AAA BBB CC D EE A";
Console.WriteLine("remove duplicate characters" + str4);
Console.Write(mystring.removeDuplicateChars(str4));
char c=mystring.firstNonRepeatedCharacter(str);
Console.WriteLine("\nThe first non repeated character in '" + str + "' is : " + c);
BinaryTree<int> btree = new BinaryTree<int>();
//btree.Root = new BinaryTreeNode<int>(1);
//btree.Root.Left = new BinaryTreeNode<int>(2);
//btree.Root.Right = new BinaryTreeNode<int>(3);
//btree.Root.Left.Left = new BinaryTreeNode<int>(4);
//btree.Root.Right.Right = new BinaryTreeNode<int>(5);
//btree.Root.Left.Left.Right = new BinaryTreeNode<int>(6);
//btree.Root.Right.Right.Right = new BinaryTreeNode<int>(7);
//btree.Root.Right.Right.Right.Right = new BinaryTreeNode<int>(8);
Random rnd = new Random();
int j;
for (int i = 0; i < 8; i++) {
j = rnd.Next (1, 20);
Console.Write (j + ",");
btree.Add (j);
}
Console.WriteLine ("");
// manual sorting?
btree.PreorderTraversal (btree.Root);
//.........这里部分代码省略.........