mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
Merge branch 'master' into heap-dev
This commit is contained in:
@ -29,9 +29,9 @@ public class linked_list {
|
||||
/* 访问链表中索引为 index 的结点 */
|
||||
static ListNode access(ListNode head, int index) {
|
||||
for (int i = 0; i < index; i++) {
|
||||
head = head.next;
|
||||
if (head == null)
|
||||
return null;
|
||||
head = head.next;
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ public class binary_search_tree {
|
||||
PrintUtil.printTree(bst.getRoot());
|
||||
|
||||
/* 查找结点 */
|
||||
TreeNode node = bst.search(5);
|
||||
TreeNode node = bst.search(7);
|
||||
System.out.println("\n查找到的结点对象为 " + node + ",结点值 = " + node.val);
|
||||
|
||||
/* 插入结点 */
|
||||
|
||||
Reference in New Issue
Block a user