Skip to content

Commit 7c9cf56

Browse files
Add files via upload
1 parent 0a742b0 commit 7c9cf56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+9388
-0
lines changed
+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {
7+
"scrolled": true
8+
},
9+
"outputs": [
10+
{
11+
"name": "stdout",
12+
"output_type": "stream",
13+
"text": [
14+
"13\n",
15+
"15\n",
16+
"15\n"
17+
]
18+
}
19+
],
20+
"source": [
21+
"class Node:\n",
22+
" \n",
23+
" def __init__(self,data):\n",
24+
" self.data = data\n",
25+
" self.next = None\n",
26+
"\n",
27+
"a = Node(13)\n",
28+
"b = Node(15) \n",
29+
"a.next = b #Reference of Node(15)\n",
30+
"\n",
31+
"print(a.data)\n",
32+
"print(b.data)\n",
33+
"print(a.next.data)"
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": 2,
39+
"metadata": {
40+
"scrolled": true
41+
},
42+
"outputs": [
43+
{
44+
"name": "stdout",
45+
"output_type": "stream",
46+
"text": [
47+
"<__main__.Node object at 0x000001B39897A7F0>\n",
48+
"<__main__.Node object at 0x000001B39897A910>\n",
49+
"<__main__.Node object at 0x000001B39897A910>\n"
50+
]
51+
}
52+
],
53+
"source": [
54+
"print(a)\n",
55+
"print(b)\n",
56+
"print(a.next)"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": 4,
62+
"metadata": {
63+
"scrolled": false
64+
},
65+
"outputs": [
66+
{
67+
"ename": "AttributeError",
68+
"evalue": "'NoneType' object has no attribute 'data'",
69+
"output_type": "error",
70+
"traceback": [
71+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
72+
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
73+
"\u001b[1;32m<ipython-input-4-4c5e4022a8f6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnext\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
74+
"\u001b[1;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'data'"
75+
]
76+
}
77+
],
78+
"source": [
79+
"print(b.next.data)"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 1,
85+
"metadata": {
86+
"scrolled": true
87+
},
88+
"outputs": [
89+
{
90+
"name": "stdout",
91+
"output_type": "stream",
92+
"text": [
93+
"20 10 "
94+
]
95+
}
96+
],
97+
"source": [
98+
"class Node:\n",
99+
" def __init__(self, data):\n",
100+
" self.data = data\n",
101+
" self.next = None\n",
102+
"def printLL(head):\n",
103+
" while head is not None:\n",
104+
" print(head.data,end=\" \")\n",
105+
" head = head.next\n",
106+
"\n",
107+
"\n",
108+
"\n",
109+
"node1 = Node(10)\n",
110+
"node2 = Node(20)\n",
111+
"node2.next = node1\n",
112+
"printLL(node2)"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": 13,
118+
"metadata": {
119+
"scrolled": true
120+
},
121+
"outputs": [
122+
{
123+
"name": "stdout",
124+
"output_type": "stream",
125+
"text": [
126+
"20 30 40 "
127+
]
128+
}
129+
],
130+
"source": [
131+
"class Node:\n",
132+
" def __init__(self,data):\n",
133+
" self.data = data\n",
134+
" self.next = None\n",
135+
"def printLL(head):\n",
136+
" while head is not None:\n",
137+
" print(head.data,end=\" \")\n",
138+
" head = head.next\n",
139+
" \n",
140+
"node1 = Node(10)\n",
141+
"node2 = Node(20)\n",
142+
"node3 = Node(30)\n",
143+
"node4 = Node(40)\n",
144+
"node1.next = node2\n",
145+
"node2.next = node3\n",
146+
"node3.next = node4\n",
147+
"printLL(node2)"
148+
]
149+
}
150+
],
151+
"metadata": {
152+
"kernelspec": {
153+
"display_name": "Python 3",
154+
"language": "python",
155+
"name": "python3"
156+
},
157+
"language_info": {
158+
"codemirror_mode": {
159+
"name": "ipython",
160+
"version": 3
161+
},
162+
"file_extension": ".py",
163+
"mimetype": "text/x-python",
164+
"name": "python",
165+
"nbconvert_exporter": "python",
166+
"pygments_lexer": "ipython3",
167+
"version": "3.8.5"
168+
}
169+
},
170+
"nbformat": 4,
171+
"nbformat_minor": 4
172+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 12,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"1 2 3 4 5 -1\n",
13+
"1->2->3->4->5->None\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"class Node:\n",
19+
" def __init__(self,data):\n",
20+
" self.data = data\n",
21+
" self.next = None\n",
22+
" \n",
23+
"def printLL(head):\n",
24+
" \n",
25+
" while head is not None:\n",
26+
" print(str(head.data) + \"->\",end=\"\")\n",
27+
" head = head.next\n",
28+
" print(\"None\")\n",
29+
" return\n",
30+
" \n",
31+
"def takeInput():\n",
32+
" \n",
33+
" inputList = [int(ele) for ele in input().split()]\n",
34+
" head = None\n",
35+
" for currData in inputList:\n",
36+
" if currData == -1:\n",
37+
" break\n",
38+
" \n",
39+
" newNode = Node(currData)\n",
40+
" if head is None:\n",
41+
" head = newNode\n",
42+
" \n",
43+
" else:\n",
44+
" curr = head\n",
45+
" while curr.next is not None:\n",
46+
" curr = curr.next\n",
47+
" curr.next = newNode\n",
48+
" \n",
49+
" return head\n",
50+
"\n",
51+
"head = takeInput()\n",
52+
"printLL(head)"
53+
]
54+
}
55+
],
56+
"metadata": {
57+
"kernelspec": {
58+
"display_name": "Python 3",
59+
"language": "python",
60+
"name": "python3"
61+
},
62+
"language_info": {
63+
"codemirror_mode": {
64+
"name": "ipython",
65+
"version": 3
66+
},
67+
"file_extension": ".py",
68+
"mimetype": "text/x-python",
69+
"name": "python",
70+
"nbconvert_exporter": "python",
71+
"pygments_lexer": "ipython3",
72+
"version": "3.8.5"
73+
}
74+
},
75+
"nbformat": 4,
76+
"nbformat_minor": 4
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"1 2 3 4 5\n",
13+
"1->2->3->4->5->None\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"class Node:\n",
19+
" def __init__(self,data):\n",
20+
" self.data = data\n",
21+
" self.next = None\n",
22+
" \n",
23+
"def printLL(head):\n",
24+
" \n",
25+
" while head is not None:\n",
26+
" print(str(head.data) + \"->\",end=\"\")\n",
27+
" head = head.next\n",
28+
" print(\"None\")\n",
29+
" return\n",
30+
" \n",
31+
"def takeInput():\n",
32+
" \n",
33+
" inputList = [int(ele) for ele in input().split()]\n",
34+
" head = None\n",
35+
" tail = None\n",
36+
" for currData in inputList:\n",
37+
" if currData == -1:\n",
38+
" break\n",
39+
" \n",
40+
" newNode = Node(currData)\n",
41+
" if head is None:\n",
42+
" head = newNode\n",
43+
" tail = newNode\n",
44+
" \n",
45+
" else:\n",
46+
" tail.next = newNode\n",
47+
" tail = newNode\n",
48+
" \n",
49+
" return head\n",
50+
"\n",
51+
"head = takeInput()\n",
52+
"printLL(head)"
53+
]
54+
}
55+
],
56+
"metadata": {
57+
"kernelspec": {
58+
"display_name": "Python 3",
59+
"language": "python",
60+
"name": "python3"
61+
},
62+
"language_info": {
63+
"codemirror_mode": {
64+
"name": "ipython",
65+
"version": 3
66+
},
67+
"file_extension": ".py",
68+
"mimetype": "text/x-python",
69+
"name": "python",
70+
"nbconvert_exporter": "python",
71+
"pygments_lexer": "ipython3",
72+
"version": "3.8.5"
73+
}
74+
},
75+
"nbformat": 4,
76+
"nbformat_minor": 4
77+
}

0 commit comments

Comments
 (0)