Run Code

API

Code Wall

Misc

Feedback

Login

Theme

Privacy

Patreon
Lab_I_4_25_11_2020
#python 3.6.9 print ("Bye, bye, World!") # Soner Berat Eren graph = { "a" : ["c"], "b" : ["c", "e"], "c" : ["a", "b", "d", "e"], "d" : ["c"], "e" : ["c", "b"], "f" : [] } # Ernesto Conjo # Madi Aliyev drew a graph graph1 = {"A":["B"] , "B":["A","D","C"], "C":["B","D"], "D":["B","C"], "E":[] } # Mavlonbek Zaynobiddinov graph2 = { "A":["E" , "C", "D"], "B" : ["D", "F"] , "C": ["E", "A" , "F"], "D": ["A", "B", "E"], "E": ["A", "C", "D"], "F": ["B", "C" ] } # Luana Arouca # Tai Con Trinh has not been there. # SumeyraMeryem Turkhan has not been there. # Shamsiddin Parpiev drew a graph (with the contribution of Nigel Arubinu) print(graph2["A"]) for key , value in graph2.items(): print("Key:", key, "value:", value) # Mohamed El Orabi # Minh Doan has been at his job and not able to work here. def generate_edges(graph): edges = [] Number_of_appends=0 for node in graph: for neighbour in graph[node]: edges.append((node, neighbour)) Number_of_appends += 1 print("The number of appends is: ", Number_of_appends) return edges print(generate_edges(graph)) # Edson Domingos print(generate_edges(graph1)) print(generate_edges(graph2)) # Soner Berat Eren # Emel Sarli drew a graph graph3 = {"A":[] , "B":[], "C":[], "D":[] } print(generate_edges(graph3)) # Ernesto Conjo came back! # Let us characterize the size of the problem in terms of the number of edges = M. # Let us also choose the measure of complexity as the number of appends. # The case of a graph without edges is the "best case". The complexity is then 0. # What is the worst case? # The worst case is associated with graphs where all vertices are connected. graph4 = {"A":["B", "C", "D", "E"] , "B":["A","D","C", "E"], "C":["B","D", "A", "E"], "D":["B","C", "A", "E"], "E":["A", "B", "C", "D"] } print(generate_edges(graph4)) # Madi Aliyev # Luana Arouca drew a graph # For M vertices, in the worst cas we have M*(M1)/2 edges = number of appends # The complexity is O(M**2). # The homework: you encountered the number 6. That number is called "perfect", # 6 = 1 + 2 + 3
run

edit

history

help
0
Lesson8
benda x guna
binary search
Lesson 9 hw
ASCII Art
Hi.py
pyEnumAuto
PyTypeSub
Determine the weight of tiles at 10 grams each
tip calculation