Last active
December 24, 2016 21:31
-
-
Save liavkoren/c4b941c58a9e0c7f0260b2b4591348f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A dictionary comprehension: | |
a = {num: Node(num) for num in range(1, 8)} | |
``` | |
a now looks like: | |
{1: Node(data=1, next_node=None), | |
2: Node(data=2, next_node=None), | |
3: Node(data=3, next_node=None), | |
4: Node(data=4, next_node=None), | |
5: Node(data=5, next_node=None), | |
6: Node(data=6, next_node=None), | |
7: Node(data=7, next_node=None)} | |
``` | |
build a linked list: | |
x = a[5] | |
x.next = a[3] | |
x.next.next = a[1] | |
etc... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A dictionary comprehension: | |
a = {num: Node(num) for num in range(1, 8)} | |
``` | |
a now looks like: | |
{1: Node(data=1, next_node=None), | |
2: Node(data=2, next_node=None), | |
3: Node(data=3, next_node=None), | |
4: Node(data=4, next_node=None), | |
5: Node(data=5, next_node=None), | |
6: Node(data=6, next_node=None), | |
7: Node(data=7, next_node=None)} | |
``` | |
build a linked list: | |
x = a[5] | |
x.next = a[3] | |
x.next.next = a[1] | |
etc... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment