forked from sirfaheem/ComputerScienceALevels
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter 23.py
More file actions
41 lines (31 loc) · 900 Bytes
/
Chapter 23.py
File metadata and controls
41 lines (31 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class nodeLister(object):
def __init__(self,d,p):
self.data = d
self.ptr = p
def dSetter(self,d):
self.data = d
def pSetter(self,p):
self.ptr = p
def pGetter(self):
return self.ptr
def dGetter(self):
return self.data
class listConstructor(object):
def initList(self,n,nodes):
self.starPtr = n
self.freePtr = 1
for i in range(1,7):
x = i+1
nodes[i].pSetter(x)
nodes[7].pSetter(n)
def main(self):
nullPtr = 0
nodes = [0]
for i in range(1,8):
nodes.append(i)
nodes[i] = nodeLister(0,0)
self.initList(nullPtr,nodes)
for i in range(1,8):
print(nodes[i].pGetter(),nodes[i].dGetter())
x = listConstructor()
x.main()