This file contains 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
# Sample array | |
alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'] | |
# Note from Alan: | |
# the array will always be the right length to produce | |
# a balanced tree where every node has two children. | |
# Decided on a list representation | |
# The end result will look like: [['A', ['B', 'I']], ['B', ['C', 'F']] . . . ] | |
final_tree = [] |
This file contains 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
simple = [['a','b','once'], ['b','c','upon'], ['c','d','a time']] | |
double = [['a','0','b','once again'], ['b','a','c','upon'], ['c','b','0','a time']] | |
simpled = {'a':['0','once'], 'b':['a', 'upon'], 'c':['b', 'a dictionary']} | |
def readsimple(start, nodes): | |
for item in nodes: | |
x = item[1] | |
if item[0] == start: | |
print item[0], item[-1] | |
readsimple(x, nodes) |