refactor: Replace 结点 with 节点 (#452)

* Replace 结点 with 节点
Update the footnotes in the figures

* Update mindmap

* Reduce the size of the mindmap.png
This commit is contained in:
Yudong Jin
2023-04-09 04:32:17 +08:00
committed by GitHub
parent 3f4e32b2b0
commit 1c8b7ef559
395 changed files with 2056 additions and 2056 deletions

View File

@ -9,13 +9,13 @@ sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
def insert(n0: ListNode, P: ListNode) -> None:
""" 在链表的点 n0 之后插入点 P """
""" 在链表的点 n0 之后插入点 P """
n1 = n0.next
P.next = n1
n0.next = P
def remove(n0: ListNode) -> None:
""" 删除链表的点 n0 之后的首个"""
""" 删除链表的点 n0 之后的首个"""
if not n0.next:
return
# n0 -> P -> n1
@ -24,7 +24,7 @@ def remove(n0: ListNode) -> None:
n0.next = n1
def access(head: ListNode, index: int) -> ListNode | None:
""" 访问链表中索引为 index 的"""
""" 访问链表中索引为 index 的"""
for _ in range(index):
if not head:
return None
@ -32,7 +32,7 @@ def access(head: ListNode, index: int) -> ListNode | None:
return head
def find(head: ListNode, target: int) -> int:
""" 在链表中查找值为 target 的首个"""
""" 在链表中查找值为 target 的首个"""
index = 0
while head:
if head.val == target:
@ -45,7 +45,7 @@ def find(head: ListNode, target: int) -> int:
""" Driver Code """
if __name__ == "__main__":
""" 初始化链表 """
# 初始化各个
# 初始化各个
n0 = ListNode(1)
n1 = ListNode(3)
n2 = ListNode(2)
@ -59,20 +59,20 @@ if __name__ == "__main__":
print("初始化的链表为")
print_linked_list(n0)
""" 插入"""
""" 插入"""
insert(n0, ListNode(0))
print("插入点后的链表为")
print("插入点后的链表为")
print_linked_list(n0)
""" 删除"""
""" 删除"""
remove(n0)
print("删除点后的链表为")
print("删除点后的链表为")
print_linked_list(n0)
""" 访问"""
""" 访问"""
node: ListNode = access(n0, 3)
print("链表中索引 3 处的点的值 = {}".format(node.val))
print("链表中索引 3 处的点的值 = {}".format(node.val))
""" 查找"""
""" 查找"""
index: int = find(n0, 2)
print("链表中值为 2 的点的索引 = {}".format(index))
print("链表中值为 2 的点的索引 = {}".format(index))