mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-25 21:23:21 +08:00
Retranslate the complete English edition from Simplified Chinese (#2010)
* Retranslate the complete English edition from Simplified Chinese * Polish three English explanations after reader-focused review
This commit is contained in:
@@ -9,31 +9,31 @@ namespace hello_algo.chapter_tree;
|
||||
public class binary_tree {
|
||||
[Test]
|
||||
public void Test() {
|
||||
/* Initialize binary tree */
|
||||
// Initialize nodes
|
||||
/* Initialize the binary tree */
|
||||
// Initialize the nodes
|
||||
TreeNode n1 = new(1);
|
||||
TreeNode n2 = new(2);
|
||||
TreeNode n3 = new(3);
|
||||
TreeNode n4 = new(4);
|
||||
TreeNode n5 = new(5);
|
||||
// Build references (pointers) between nodes
|
||||
// Set up references (pointers) between the nodes
|
||||
n1.left = n2;
|
||||
n1.right = n3;
|
||||
n2.left = n4;
|
||||
n2.right = n5;
|
||||
Console.WriteLine("\nInitialize binary tree\n");
|
||||
Console.WriteLine("\nInitialize the binary tree\n");
|
||||
PrintUtil.PrintTree(n1);
|
||||
|
||||
/* Insert node P between n1 -> n2 */
|
||||
/* Insert and remove nodes */
|
||||
TreeNode P = new(0);
|
||||
// Delete node
|
||||
// Insert node P between n1 and n2 in n1 -> n2
|
||||
n1.left = P;
|
||||
P.left = n2;
|
||||
Console.WriteLine("\nAfter inserting node P\n");
|
||||
Console.WriteLine("\nAfter inserting node P:\n");
|
||||
PrintUtil.PrintTree(n1);
|
||||
// Remove node P
|
||||
n1.left = n2;
|
||||
Console.WriteLine("\nAfter removing node P\n");
|
||||
Console.WriteLine("\nAfter removing node P:\n");
|
||||
PrintUtil.PrintTree(n1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user