#!/usr/local/bin/ruby
NUM_ITEMS=3
def swap(numbers, root, bottom)
done = 0
puts "swapping root and maxChild\n"
temp = numbers[root]
numbers[root] = numbers[bottom]
numbers[bottom] = temp
root = bottom
#for i in 0..bottom do
# printf("numbers[%d] = %d \n",i,numbers[i])
#end
end
numbers = Array.new
for i in 0..NUM_ITEMS do
numbers[i] = rand(1000)
end
puts "randome numbers\n"
for i in 0..NUM_ITEMS do
printf("%d \n",numbers[i])
end
root = 0
bottom = 1
swap(numbers, root, bottom) # swap 0 and 1
swap(numbers, 2, 3) # swap 2 and 3
puts "Sorted numbers\n"
for i in 0..NUM_ITEMS do
printf("%d \n",numbers[i])
end