project2/p2q2-ucs.rb
def sift_up(i)
    parent = (i - 1) / 2
    if parent >= 0 and @heap[parent][1] > @heap[i][1]
      @heap[parent], @heap[i] = @heap[i], @heap[parent]
      sift_up(parent)
    end
  end
# Sift up the element at index i
Sift up the element at index i
Sift up the element at index i
def sift_up(i)
    parent = (i - 1) / 2
    if parent >= 0 and @heap[parent][1] > @heap[i][1]
      @heap[parent], @heap[i] = @heap[i], @heap[parent]
      sift_up(parent)
    end
  end
def sift_up ( i ) parent = ( i - 1 ) / 2 if parent >= 0 and @heap [ parent ] [ 1 ] > @heap [ i ] [ 1 ] @heap [ parent ] , @heap [ i ] = @heap [ i ] , @heap [ parent ] sift_up ( parent ) end end
Sift up the element at index i
Sift up the element at index i
i