Skip to content

Instantly share code, notes, and snippets.

@Supernats
Created April 29, 2014 02:16
Show Gist options
  • Save Supernats/11389248 to your computer and use it in GitHub Desktop.
Save Supernats/11389248 to your computer and use it in GitHub Desktop.
# line by line printing of array representation of full binary tree
def print_tree(els)
Math.log2(els.length).times do |i|
row = els.shift(2 ** i)
puts row
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment