Difference between revisions of "NodePractice1.py"

From WLCS
(Created page with "<syntaxhighlight lang="Python"> class Node: def __init__(self): self.data = 0 self.next = None #Draw the memory diagram of the following code a = Nod...")
 
 
Line 7: Line 7:
 
#Draw the memory diagram of the following code
 
#Draw the memory diagram of the following code
 
a = Node()
 
a = Node()
a.num = 20
+
a.data = 20
 
b = Node()
 
b = Node()
 
a.next = b
 
a.next = b
b.num = 13
+
b.data = 13
 
b.next = Node()
 
b.next = Node()
b.next.num = 14
+
b.next.data = 14
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 08:45, 18 October 2013

class Node:
    def __init__(self):
        self.data = 0
        self.next = None
        
#Draw the memory diagram of the following code
a = Node()
a.data = 20
b = Node()
a.next = b
b.data = 13
b.next = Node()
b.next.data = 14