#!/usr/bin/env python import sys import os """ Author : flo date : 2016.12.09 Purpose : example of AVL tree computation with simplified recursive equations Comments: It prints out math equations for finding out the minimum amount of Nodes : in an AVL Tree just shy of doing the math for you. : rather than printing out the answer it prints out the math equations : depending on your input in the command prompt on windose or linux. : first rename this file from avlTree.txt to avlTree.py usage : python avlTree.py 10 """ # printing out the AVL def prtAVL(n): a=0 while a < n: if a == 0: print "S("+str(a)+")"+" = 1" a=a+1 elif a == 1: print "S("+str(a)+")"+" = 2" a=a+1 else: print "S("+str(a)+") = S("+str(a)+" - 1) + S("+str(a)+" - 2) + 1 = " + " You can do the Math !" a=a+1 # main hobbit def main(): value = int(sys.argv[1]) prtAVL(value) # calling main hobbit if __name__ == "__main__": main()