mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-14 04:30:58 +00:00
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:
@@ -15,7 +15,7 @@ func hashingSearchArray(map: [Int: Int], target: Int) -> Int {
|
||||
|
||||
/* 哈希查找(链表) */
|
||||
func hashingSearchLinkedList(map: [Int: ListNode], target: Int) -> ListNode? {
|
||||
// 哈希表的 key: 目标结点值,value: 结点对象
|
||||
// 哈希表的 key: 目标节点值,value: 节点对象
|
||||
// 若哈希表中无此 key ,返回 null
|
||||
return map[target]
|
||||
}
|
||||
@@ -41,10 +41,10 @@ enum HashingSearch {
|
||||
// 初始化哈希表
|
||||
var map1: [Int: ListNode] = [:]
|
||||
while head != nil {
|
||||
map1[head!.val] = head! // key: 结点值,value: 结点
|
||||
map1[head!.val] = head! // key: 节点值,value: 节点
|
||||
head = head?.next
|
||||
}
|
||||
let node = hashingSearchLinkedList(map: map1, target: target)
|
||||
print("目标结点值 3 的对应结点对象为 \(node!)")
|
||||
print("目标节点值 3 的对应节点对象为 \(node!)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ func linearSearchLinkedList(head: ListNode?, target: Int) -> ListNode? {
|
||||
var head = head
|
||||
// 遍历链表
|
||||
while head != nil {
|
||||
// 找到目标结点,返回之
|
||||
// 找到目标节点,返回之
|
||||
if head?.val == target {
|
||||
return head
|
||||
}
|
||||
head = head?.next
|
||||
}
|
||||
// 未找到目标结点,返回 null
|
||||
// 未找到目标节点,返回 null
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -48,6 +48,6 @@ enum LinearSearch {
|
||||
/* 在链表中执行线性查找 */
|
||||
let head = ListNode.arrToLinkedList(arr: nums)
|
||||
let node = linearSearchLinkedList(head: head, target: target)
|
||||
print("目标结点值 3 的对应结点对象为 \(node!)")
|
||||
print("目标节点值 3 的对应节点对象为 \(node!)")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user