Skip to content

Commit fc7a7aa

Browse files
committed
add debug prints for adjacency list and indegree dictionary
1 parent 93b063c commit fc7a7aa

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

Data Structures and Algorithms (English)/7-18_Hashing - Hard Version (30).py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def reconstruct(seq, n):
2020
j = (j + 1) % n
2121
indeg.setdefault(x, 0) # ensure present even if 0
2222

23+
print(adj)
24+
print(indeg)
25+
2326
# topo sort, smallest first
2427
heap = [k for k in keys if indeg.get(k, 0) == 0]
2528
heapq.heapify(heap)
@@ -40,12 +43,15 @@ def reconstruct(seq, n):
4043
print(" ".join(map(str, reconstruct(table, n))))
4144

4245
"""
43-
adj: {
44-
12: {1, 13},
45-
34: {1, 12, 13},
46-
27: {38},
47-
22: {33, 34, 1, 38, 12, 13, 27},
48-
32: {33, 1, 34, 38, 12, 13, 21, 22, 27}
49-
}
50-
indeg: {33: 0, 1: 0, 13: 0, 12: 2, 34: 3, 38: 0, 27: 1, 22: 7, 32: 9, 21: 0}
46+
{
47+
1: {32, 34, 12, 22},
48+
13: {32, 34, 12, 22},
49+
12: {32, 34, 22},
50+
38: {32, 27, 22},
51+
33: {32, 22},
52+
34: {32, 22},
53+
27: {32, 22},
54+
21: {32},
55+
22: {32}}
56+
{33: 0, 1: 0, 13: 0, 12: 2, 34: 3, 38: 0, 27: 1, 22: 7, 32: 9, 21: 0}
5157
"""

0 commit comments

Comments
 (0)