From 3d3d5aad65e36769009a9be3b4396d30aff5e430 Mon Sep 17 00:00:00 2001 From: VarshiniShreeV Date: Sun, 27 Oct 2024 10:29:55 +0530 Subject: [PATCH] Fixed --- sorts/topological_sort.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sorts/topological_sort.py b/sorts/topological_sort.py index 74c3432bc..2cb003d76 100644 --- a/sorts/topological_sort.py +++ b/sorts/topological_sort.py @@ -21,16 +21,16 @@ def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[st current = start # Mark the current node as visited visited.append(current) - # List of all neighbours of current node + # List of all neighbors of current node neighbors = edges[current] - # Traverse all neighbours of the current node + # Traverse all neighbors of the current node for neighbor in neighbors: - # Recursively visit each unvisited neighbour + # Recursively visit each unvisited neighbor if neighbor not in visited: sort = topological_sort(neighbor, visited, sort) - # After visiting all neigbours, add the current node to the sorted list + # After visiting all neigbors, add the current node to the sorted list sort.append(current) # If there are some nodes that were not visited (disconnected components)