Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Creating a Binary Tree
|
637
if (rightNode != null)
{
retObj = rightNode.DepthFirstSearch(targetObj);
}
}
else if (comparisonResult < 0)
{
if (leftNode != null)
{
retObj = leftNode.DepthFirstSearch(targetObj);
}
}
return (retObj);
}
public void PrintDepthFirst( )
{
if (leftNode != null)
{
leftNode.PrintDepthFirst( );
}
Console.WriteLine(this.nodeValue.ToString( ));
if (leftNode != null)
{
Console.WriteLine("\tContains Left: " +
leftNode.nodeValue.ToString( ));
}
else
{
Console.WriteLine("\tContains Left: NULL");
}
if (rightNode != null)
{
Console.WriteLine("\tContains Right: " +
rightNode.nodeValue.ToString( ));
}
else
{
Console.WriteLine("\tContains Right: NULL");
}
if (rightNode != null)
{
rightNode.PrintDepthFirst( );
}
}
public List<T> IterateDepthFirst( )
{
Example 11-11. Generic BinaryTreeNode class (continued)
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
638
|
Chapter 11: Data Structures and Algorithms
The methods defined in Table 11-4 are of particular interest to using a BinaryTree<T>
object.
List<T> tempList = new List<T>( );
if (leftNode != null)
{
tempList.AddRange(leftNode.IterateDepthFirst( ));
}
if ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata