mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-09 22:16:06 +00:00
update zig codes for Section 'Heap' (heap.zig)
This commit is contained in:
@@ -23,8 +23,8 @@ pub fn TreeNode(comptime T: type) type {
|
||||
};
|
||||
}
|
||||
|
||||
// Generate a binary tree with an array (through TailQueue)
|
||||
pub fn arrQueToTree(comptime T: type, mem_allocator: std.mem.Allocator, arr: []T) !?*TreeNode(T) {
|
||||
// Generate a binary tree with an array
|
||||
pub fn arrToTree(comptime T: type, mem_allocator: std.mem.Allocator, arr: []T) !?*TreeNode(T) {
|
||||
if (arr.len == 0) return null;
|
||||
var root = try mem_allocator.create(TreeNode(T));
|
||||
root.init(arr[0]);
|
||||
|
||||
Reference in New Issue
Block a user