Example #1
0
from bintreeFile import Bintree
sv = Bintree()
sv.put('beda')
sv.put('ada')
sv.put('caesar')
sv.write()
    word_letter_list = []
    i = 0
    for letter in WORD:
        word_letter_list = list(WORD)

        for letter in alphabet:
            word_letter_list[i] = letter
            new_word = ''.join(word_letter_list)

            if new_word != WORD and swe_tree.exists(new_word) and not (
                    old_tree.exists(new_word)):
                old_tree.put(new_word)
        i += 1


swe_tree = Bintree()
old_tree = Bintree()

file_name = "word3.txt"
f = open(file_name, "r", encoding="utf-8")
for line in f:
    swe_tree.put(line.replace("\n", ""))
f.close()

start_word = "söt"
end_word = "sur"

make_children(start_word)

print(old_tree.write())
Example #3
0
		t0 = time.time()
		if svenska.exists(int(search)):
			search_time = time.time() - t0	
			print('Binärsökningen tog ' + str(search_time*1000000) + ' mikrosekunder\n')

		t0 = time.time()
		for n in slumplista:
			if n == int(search):
				break
		print('Linjärsökningen tog ' + str((time.time() - t0)*1000000) + ' mikrosekunder\n')

		print(slumplista[0:10])
=======
    svenska = Bintree()
    svenska.put('gurka')
    svenska.put('ananas')
    svenska.put('ödla')
    svenska.put('gurra')
    svenska.put('tomat')
    svenska.put('luleå')
    svenska.put('choklad')
    
    if svenska.exists('ananas'):
        print('\nAnanas aer med i tradet!\n')
        
    print("traedet inneholler: \n")
    svenska.write()
    print("rooten aer: " + str(svenska.root))
>>>>>>> 21da2736d026dbb85f54511314f6ad63b9551424

main()
Example #4
0
from bintreeFile import Bintree, Node
svenska = Bintree()              # Skapa ett trädobjekt
svenska.put("gurka")		    # Sortera in "gurka" i trädet	
if svenska.exists("gurka"):      # Kolla om "gurka" finns i trädet
   svenska.write()                  # Skriver alla ord i bokstavsordning
Example #5
0
from bintreeFile import Bintree

print("\n")
svenska = Bintree()
with open("word3.txt", "r", encoding = "utf-8") as svenskfil:
    for rad in svenskfil:
        ordet = rad.strip()                # Ett trebokstavsord per rad
        if ordet in svenska:
            print(ordet, end = " ") 
        else:
            svenska.put(ordet)             # in i sökträdet
print("\n")
if input("Vill du skiva ut den svenska ordlistan? (y):") == "y": 
    svenska.write()

engelska=Bintree()
with open("engelska.txt", "r", encoding = "utf-8") as engfil:
	for rad in engfil:
		ordet=rad.strip(",")
		for ordet in rad.split():
			if not(ordet in engelska):
				engelska.put(ordet)
				if ordet in svenska:
						print(ordet, end = " ")
if input("Vill du skiva ut den engelska ordlistan? (y):") == "y": 
    engelska.write()