binary_trees 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/binary_trees.rb +3 -3
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ab09804a82e404db72425b9848e6f1d8ead807424e24770a3c2d640a30e2879
4
- data.tar.gz: b099346161b1732014822603e4f616ab4d0729b083952974c56b7c89746eca7f
3
+ metadata.gz: deb2f09d612a3ed0b194d61168c4eac9c7862079844f0115f8594fdb4d396ba5
4
+ data.tar.gz: e0ad988c59677dc0a1b9105ebab038dda521dcf451337378b3033720da50e057
5
5
  SHA512:
6
- metadata.gz: 45477346a529f82ea8241fcadfff3377b3c94e7889b7bb9c6651b776ae2035c863d7b1593092a69ae9bbd7ddd6759fce921c9dcb806ea59c7d0d3d281d2a36e7
7
- data.tar.gz: e11822bb88ced9f91e3b366bb07a835ce335825245c5e0167aa664bae4befcaf669def1d9651f42dbcd1197a63db65398bbe7e224ac97457f1f170a52e74bd31
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 to_array(root = @root, arr = [], idx = 0)
34
+ def to_a(root = @root, arr = [], idx = 0)
35
35
  return [] if root.nil?
36
36
 
37
37
  arr[idx] = root.val
38
- to_array(root.left, arr, idx * 2 + 1) if root.left
39
- to_array(root.right, arr, idx * 2 + 2) if root.right
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.1
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-30 00:00:00.000000000 Z
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. Given a tree and can sum all
42
- the tree node values.
41
+ summary: Convert a binary tree to array and vice versa.
43
42
  test_files: []