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:
Yudong Jin
2026-10-31 03:35:51 +08:00
committed by GitHub
parent ef46e2ed95
commit 14c314c08c
1502 changed files with 29459 additions and 23517 deletions

View File

@@ -15,7 +15,7 @@ public class ListNode {
val = x;
}
/* Deserialize a list into a linked list */
/* Deserialize an array into a linked list */
public static ListNode arrToLinkedList(int[] arr) {
ListNode dum = new ListNode(0);
ListNode head = dum;

View File

@@ -19,7 +19,7 @@ class Trunk {
};
public class PrintUtil {
/* Print matrix (Array) */
/* Print a matrix (array) */
public static <T> void printMatrix(T[][] matrix) {
System.out.println("[");
for (T[] row : matrix) {
@@ -28,7 +28,7 @@ public class PrintUtil {
System.out.println("]");
}
/* Print matrix (List) */
/* Print a matrix (list) */
public static <T> void printMatrix(List<List<T>> matrix) {
System.out.println("[");
for (List<T> row : matrix) {
@@ -37,7 +37,7 @@ public class PrintUtil {
System.out.println("]");
}
/* Print linked list */
/* Print a linked list */
public static void printLinkedList(ListNode head) {
List<String> list = new ArrayList<>();
while (head != null) {
@@ -47,13 +47,13 @@ public class PrintUtil {
System.out.println(String.join(" -> ", list));
}
/* Print binary tree */
/* Print a binary tree */
public static void printTree(TreeNode root) {
printTree(root, null, false);
}
/**
* 打印二叉树
* Print a binary tree
* This tree printer is borrowed from TECHIE DELIGHT
* https://www.techiedelight.com/c-program-print-binary-tree/
*/
@@ -97,19 +97,19 @@ public class PrintUtil {
System.out.print(p.str);
}
/* Print hash table */
/* Print the hash table */
public static <K, V> void printHashMap(Map<K, V> map) {
for (Map.Entry<K, V> kv : map.entrySet()) {
System.out.println(kv.getKey() + " -> " + kv.getValue());
}
}
/* Print heap (priority queue) */
/* Print a heap (priority queue) */
public static void printHeap(Queue<Integer> queue) {
List<Integer> list = new ArrayList<>(queue);
System.out.print("Heap array representation:");
System.out.print("Array representation of the heap:");
System.out.println(list);
System.out.println("Heap tree representation:");
System.out.println("Tree representation of the heap:");
TreeNode root = TreeNode.listToTree(list);
printTree(root);
}

View File

@@ -12,19 +12,19 @@ import java.util.*;
public class TreeNode {
public int val; // Node value
public int height; // Node height
public TreeNode left; // Reference to left child node
public TreeNode right; // Reference to right child node
public TreeNode left; // Reference to the left child
public TreeNode right; // Reference to the right child
/* Constructor */
public TreeNode(int x) {
val = x;
}
// For the serialization encoding rules, please refer to:
// https://www.hello-algo.com/chapter_tree/array_representation_of_tree/
// Array representation of binary tree:
// For the serialization rules, see:
// https://www.hello-algo.com/en/chapter_tree/array_representation_of_tree/
// Array representation of the binary tree:
// [1, 2, 3, 4, None, 6, 7, 8, 9, None, None, 12, None, None, 15]
// Linked list representation of binary tree:
// Linked representation of the binary tree:
// /——— 15
// /——— 7
// /——— 3

View File

@@ -16,7 +16,7 @@ public class Vertex {
this.val = val;
}
/* Input value list vals, return vertex list vets */
/* Given the array of values vals, return the array of vertices vets */
public static Vertex[] valsToVets(int[] vals) {
Vertex[] vets = new Vertex[vals.length];
for (int i = 0; i < vals.length; i++) {
@@ -25,7 +25,7 @@ public class Vertex {
return vets;
}
/* Input vertex list vets, return value list vals */
/* Given the list of vertices vets, return the list of values vals */
public static List<Integer> vetsToVals(List<Vertex> vets) {
List<Integer> vals = new ArrayList<>();
for (Vertex vet : vets) {