-
Notifications
You must be signed in to change notification settings - Fork 0
/
double_linked_list.py
115 lines (101 loc) · 2.24 KB
/
double_linked_list.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
class node:
def __init__(self,data):
self.data=data
self.prev=None
class sll():
def __init__(self,n):
self.head=None
num=n
print(num)
def display(self):
if self.head==None:
print('empty linked list...')
else:
temp=self.head
while temp:
print(temp.data,end=' ')
temp=temp.next
print('PRINTING DEFAULT NUMBER IN SLL')
l=sll('WELCOME TO THE SINGLE LINKED LIST...')
n1=node(10)
n2=node(20)
n3=node(30)
n4=node(40)
'''
l.head=n1
n1.next=n2
n2.next=n3
n3.next=n4
'''
l.head=n1
n1.next=n2
n2.next=n3
n3.next=n4
n4.next=None
n1.prev=None
n2.prev=n1
n3.prev=n2
n4.prev=n3
l.display()
print('\n')
print('PRINTING KEYS FROM USER & GETTING VALUES FROM DICTIONARY')
l=sll('WELCOME TO THE SINGLE LINKED LIST...')
ll={'16':'charan','58':'prabhu','a0':'shree','52':'nikhil'}
n1=node(ll[input('enter : ')])
n2=node(ll[input('enter : ')])
n3=node(ll[input('enter : ')])
n4=node(ll[input('enter : ')])
l.head=n1
n1.next=n2
n2.next=n3
n3.next=n4
n4.next=None
n1.prev=None
n2.prev=n1
n3.prev=n2
n4.prev=n3
l.display()
class nodee:
def __init__(self,data):
self.data=data
self.prev=None
class dll():
def __init__(self,n):
self.head=None
num=n
print(num)
def display(self):
n=''
n+=temp.data
if self.head==None:
print('empty linked list...')
else:
print(temp.data,end='-->')
"""
print('\n.........................DOUT ON THE PROCESS.........................................')
print('PRINTING N VALUES INPUT FROM USER OF MONTHS ')
l=dll('WELCOME TO THE SINGLE LINKED LIST...')
n=int(input('''PRINTING VALUES TAKING KEYS FROM USER AND GETTING VALUES
FROM DICTIONARY : '''))
for i in range(1,n+1):
z={1:'january',
2:'february',
3:'march',
4:'april',
5:'may',
6:'june',
7:'july',
8:'august',
9:'september',
10:'october',
11:'november',
12:'december'}
l.display()
print('\n.....................................................................')
"""
'''
for i in range(3):
a=i
n='n'+str(i)
print(n)
'''