-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.py
65 lines (64 loc) · 1.95 KB
/
menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from MKnode import *
from main import *
import time
import os
while True:
os.system("cls")
# os.system("clear")
print("!!!HELLO TO BINARY TREE!!!\n")
print("CHOOSE AN OPTION"+"\n")
print("1-BINARY SEARCH TREE (BST)")
print("2-MIN HEAP")
print("3-MAX HEAP\n")
print("4-EXIT")
choice = input("\n\n--> ")
if choice == "1":
os.system("cls")
# os.system("clear")
bst = BST_Node(None)
print("INSERT A BST\n")
nodes = int(input("ENTER THE NUM OF NODES\n\n-->"))
for i in range(nodes):
node = int(input("ENTER NUM\n-->"))
bst.insert(node)
os.system("cls")
# os.system("clear")
bst.display()
input()
elif choice == "2":
os.system("cls")
print("INSERT A MIN HEAP\n")
# os.system("clear")
elements = int(input("ENTER NUM OF ELEMENTS\n-->"))
minh = Min_Heap(elements)
for ii in range(elements):
node = int(input("ENTER NUM\n-->"))
minh.insert(node)
minhlist = minh.prints()
dll = Node(minhlist[0])
dll.convert_array_to_doubly_linked_list(minhlist)
os.system("cls")
# os.system("clear")
dll.display()
input()
elif choice == "3":
os.system("cls")
print("INSERT A MAX HEAP\n")
# os.system("clear")
elements = int(input("ENTER NUM OF ELEMENTS\n-->"))
maxh = Max_heap(elements)
for ii in range(elements):
node = int(input("ENTER NUM\n-->"))
maxh.insert(node)
maxhlist = maxh.prints()
dll = Node(maxhlist[0])
dll.convert_array_to_doubly_linked_list(maxhlist)
os.system("cls")
# os.system("clear")
dll.display()
input()
elif choice == "4":
break
else:
print("YOU ENTER WRONG NUM")
time.sleep(0.5)