Difference between revisions of "NodePractice2.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 n1 = No...")
 
 
Line 10: Line 10:
 
n2.next = Node()
 
n2.next = Node()
 
n1.next = n2.next
 
n1.next = n2.next
n1.num = 2
+
n1.data = 2
n2.num = 4
+
n2.data = 4
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 08:49, 18 October 2013

class Node:
    def __init__(self):
        self.data = 0
        self.next = None
        
#Draw the memory diagram of the following code
n1 = Node()
n2 = Node()
n2.next = Node()
n1.next = n2.next
n1.data = 2
n2.data = 4