Merge pull request #47 from Doppon/fix-ruby-syntax

Fix syntax of ruby code, and Unify the naming convention with snake case
This commit is contained in:
Stepfen Shawn 2020-05-14 23:00:00 +08:00 committed by GitHub
commit 26a7610238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 101 additions and 105 deletions

View file

@ -14,7 +14,7 @@ def heap_sort(array)
adjusted_down(adjusted_array, 1, array_size)
end
adjusted_array.drop(1)
end
end
#Method to adjust heap in downward manner
def adjusted_down(adjusted_array, parent, limit)
@ -28,7 +28,6 @@ def adjusted_down(adjusted_array, parent, limit)
adjusted_array[parent] = top
end
#Code for testing heapsort
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15].shuffle
print heap_sort(array)

View file

@ -76,5 +76,4 @@ class SingleList
def isEmpty()
return (@head==nil)
end
end

View file

@ -15,9 +15,9 @@ def inorder_traversal(root)
if node != nil
traverse(node.left, ans)
ans.push(node.val)
traverse(node.right,ans)
traverse(node.right, ans)
end
end
traverse(root,ans)
traverse(root, ans)
return ans
end

View file

@ -14,10 +14,10 @@ def postorder_traversal(root)
def traverse(node, ans)
if node != nil
traverse(node.left, ans)
traverse(node.right,ans)
traverse(node.right, ans)
ans.push(node.val)
end
end
traverse(root,ans)
traverse(root, ans)
return ans
end

View file

@ -15,9 +15,9 @@ def preorder_traversal(root)
if node != nil
ans.push(node.val)
traverse(node.left, ans)
traverse(node.right,ans)
traverse(node.right, ans)
end
end
traverse(root,ans)
traverse(root, ans)
return ans
end

View file

@ -12,5 +12,3 @@ end
puts "GCD(3, 5) = " + euclidean_gcd(3, 5).to_s
puts "GCD(3, 6) = " + euclidean_gcd(3, 6).to_s
puts "GCD(6, 3) = " + euclidean_gcd(6, 3).to_s