14 marzo 2024 - esercizio 5 #21
Unanswered
CuriousCI
asked this question in
Esercitazioni 1
Replies: 4 comments
-
1)
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Ord_topologico(G){ Dfs_ord(G,v,Vis,L){
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Penso sia impossibile avere tutti gli ordinamenti topologici in O(n+m) |
Beta Was this translation helpful? Give feedback.
0 replies
-
def OrdineTopologico(G, vis = [0...0])
ordine = []
for x in v(G){
if vis[x] != 0{
ordina(G, vis, x)
}
}
return ordine
def ordina(G, vis, x, ordine)
vis[x] = 1
for w in v.adiacenti(){
if vis[w] == 0{
ordina(G, vis, w)
}
}
ordine.insert(x)
//O(n+m) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Fornire un algoritmo in pseudo-codice che dato un grafo diretto e aciclico$G = (V, E)$ , restituisce un ordinamento topologico di $G$ . È possibile implementarlo in modo che il tempo di esecuzione sia $\theta(|V|+|E|)$ ?
Come dovrebbe essere modificato tale algoritmo per restituire l’elenco di tutti gli ordinamenti topologici di$G$ ? È possibile fare questa ulteriore modifica mantenendo lo stesso tempo di esecuzione?
Beta Was this translation helpful? Give feedback.
All reactions