Skip to content

Instantly share code, notes, and snippets.

View jithinabraham's full-sized avatar

Jithin jithinabraham

  • ClearStack India Pvt. Ltd.
  • Bangalore
View GitHub Profile
@jithinabraham
jithinabraham / heap_sort.rb
Created July 4, 2016 19:36
Heap sort in Ruby
class HeapSort
attr_accessor :input
def initialize(arg)
@input=arg
end
def heap_sort
heapify
the_end=input.length-1
@jithinabraham
jithinabraham / graph.rb
Last active January 5, 2024 03:31
Dijkstra's algorithm implemented in ruby
#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