binary_trees 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/binary_trees.rb +3 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deb2f09d612a3ed0b194d61168c4eac9c7862079844f0115f8594fdb4d396ba5
|
4
|
+
data.tar.gz: e0ad988c59677dc0a1b9105ebab038dda521dcf451337378b3033720da50e057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf057e2c63df3891ea91e32da2c0e4a3544563e200f25405ee767735da277f85a4ba277836a4b5108bbf8b57d2a80b23c59935b05767d1926f1d40ba6721814e
|
7
|
+
data.tar.gz: 8a4eae170d17f7d7b71e00a27c8cf6297da7744b6247f98c0c7281a0c34daccb98da4e942ca200398478ae05a83c7995ee48cc17c2db8d3b2e45aa8af73edc37
|
data/lib/binary_trees.rb
CHANGED
@@ -31,12 +31,12 @@ class Tree
|
|
31
31
|
root.val + sum(root.left) + sum(root.right)
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def to_a(root = @root, arr = [], idx = 0)
|
35
35
|
return [] if root.nil?
|
36
36
|
|
37
37
|
arr[idx] = root.val
|
38
|
-
|
39
|
-
|
38
|
+
to_a(root.left, arr, idx * 2 + 1) if root.left
|
39
|
+
to_a(root.right, arr, idx * 2 + 2) if root.right
|
40
40
|
arr
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binary_trees
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Queenie Peng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -38,6 +38,5 @@ requirements: []
|
|
38
38
|
rubygems_version: 3.1.4
|
39
39
|
signing_key:
|
40
40
|
specification_version: 4
|
41
|
-
summary: Convert a binary tree to array and vice versa.
|
42
|
-
the tree node values.
|
41
|
+
summary: Convert a binary tree to array and vice versa.
|
43
42
|
test_files: []
|