This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HeapSort | |
attr_accessor :input | |
def initialize(arg) | |
@input=arg | |
end | |
def heap_sort | |
heapify | |
the_end=input.length-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ruby 2.3.1 recomended | |
class Graph | |
attr_reader :graph, :nodes, :previous, :distance #getter methods | |
INFINITY = 1 << 64 | |
def initialize | |
@graph = {} # the graph // {node => { edge1 => weight, edge2 => weight}, node2 => ... | |
@nodes = Array.new | |
end |