feat: add Swift codes for heap article (#306)

* feat: add Swift codes for heap article

* Update heap.md

---------

Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
nuomi1
2023-01-29 14:03:30 +08:00
committed by GitHub
parent 29b096d90d
commit 08bfa0669a
4 changed files with 273 additions and 3 deletions

View File

@@ -74,4 +74,12 @@ public enum PrintUtil {
print("\(key) -> \(value)")
}
}
public static func printHeap(queue: [Int]) {
print("堆的数组表示:", terminator: "")
print(queue)
print("堆的树状表示:")
let root = TreeNode.listToTree(list: queue)
printTree(root: root)
}
}