Skip to content

Commit 8e2fa2f

Browse files
committed
python-practice
1 parent 3edaad6 commit 8e2fa2f

12 files changed

Lines changed: 1835 additions & 0 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
## python-practice
2+
3+
- Python-data-structure
4+
- Python-interview
5+
- Python-leetcode
6+
- Python-library
7+
- Understand-Python
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"#### General Data Structures\n",
8+
"The various data structures in computer science are divided broadly \n",
9+
"into two categories shown below"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"#### LINER DATA STRUCTURES\n",
17+
"\n",
18+
"- Array:It is a sequential arrangement of data elements paired with the index of the data element.\n",
19+
"- Linked List: Each data element contains a link to another element along with the data present in it.\n",
20+
"- Stack: LIFO(last in First Out ) or FILO(First in Last Out)\n",
21+
"- Queue: Only FIFO(First In First Out)\n",
22+
"- Matrix: It is two dimensional data structure in which the data element is referred by a pair of indices"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"metadata": {},
28+
"source": [
29+
"#### NON-LINER DATA STRUCTURES\n",
30+
"- Binary Tree: It is a data structure where each data element can be connected to maximum two other data elements and it starts with a root node.\n",
31+
"- Heap: It is a special case of Tree data structure where the data in the parent node is either strictly greater than/ equal to the child nodes or strictly less than it’s child nodes.\n",
32+
"- Hash Table: It is a data structure which is made of arrays associated with each other using a hash function. It retrieves values using keys rather than index from a data element.\n",
33+
"- Graph: .It is an arrangement of vertices and nodes where some of the nodes are connected to each other through links."
34+
]
35+
},
36+
{
37+
"cell_type": "markdown",
38+
"metadata": {},
39+
"source": [
40+
"#### PYTHON SPECIFIC DATA STRUCTURES\n",
41+
"- List: It is similar to array with the exception that the data elements can be of different data types. You can have both numeric and string data in a python list.\n",
42+
"- Tuple: Tuples are similar to lists but they are immutable which means the values in a tuple cannot be modified they can only be read.\n",
43+
"- Dictionary: The dictionary contains Key-value pairs as its data elements."
44+
]
45+
}
46+
],
47+
"metadata": {
48+
"kernelspec": {
49+
"display_name": "python pratice",
50+
"language": "python",
51+
"name": "env_name"
52+
},
53+
"language_info": {
54+
"codemirror_mode": {
55+
"name": "ipython",
56+
"version": 3
57+
},
58+
"file_extension": ".py",
59+
"mimetype": "text/x-python",
60+
"name": "python",
61+
"nbconvert_exporter": "python",
62+
"pygments_lexer": "ipython3",
63+
"version": "3.7.1"
64+
},
65+
"toc": {
66+
"base_numbering": 1,
67+
"nav_menu": {},
68+
"number_sections": true,
69+
"sideBar": true,
70+
"skip_h1_title": false,
71+
"title_cell": "Table of Contents",
72+
"title_sidebar": "Contents",
73+
"toc_cell": false,
74+
"toc_position": {},
75+
"toc_section_display": true,
76+
"toc_window_display": false
77+
}
78+
},
79+
"nbformat": 4,
80+
"nbformat_minor": 2
81+
}
Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"#### Array Representation\n",
8+
"Arrays can be declared in various ways in different languages and these items should be of the same type\n",
9+
"![Array Representation](https://www.tutorialspoint.com/data_structures_algorithms/images/array_declaration.jpg)\n",
10+
"![](https://www.tutorialspoint.com/data_structures_algorithms/images/array_representation.jpg)"
11+
]
12+
},
13+
{
14+
"cell_type": "markdown",
15+
"metadata": {},
16+
"source": [
17+
"#### Basic Operations\n",
18+
"- Traverse\n",
19+
"- Insertion\n",
20+
"- Deletion\n",
21+
"- Search\n",
22+
"- Update"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"metadata": {},
28+
"source": [
29+
"Array is created in Python by importing array module to the python program . Then the array is declared as shown below."
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": 2,
35+
"metadata": {
36+
"ExecuteTime": {
37+
"end_time": "2019-05-23T07:01:22.031150Z",
38+
"start_time": "2019-05-23T07:01:22.026914Z"
39+
}
40+
},
41+
"outputs": [],
42+
"source": [
43+
"from array import *\n",
44+
"\n",
45+
"array_name = array(typecode, [Initializers])"
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"metadata": {},
51+
"source": [
52+
"Typecode are the codes that are used to define the type of value the array will hold. Some common typecodes used are:\n",
53+
"\n",
54+
"Typecode Value\n",
55+
"- b\t: signed integer of size 1 byte \n",
56+
"- B\t: unsigned integer of size 1 byte\n",
57+
"- c\t: character of size 1 byte\n",
58+
"- i\t: signed integer of size 2 bytes\n",
59+
"- I\t: unsigned integer of size 2 bytes\n",
60+
"- f\t: floating point of size 4 bytes\n",
61+
"- d\t: floating point of size 8 bytes"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 3,
67+
"metadata": {
68+
"ExecuteTime": {
69+
"end_time": "2019-05-23T07:06:41.672138Z",
70+
"start_time": "2019-05-23T07:06:41.664693Z"
71+
}
72+
},
73+
"outputs": [
74+
{
75+
"name": "stdout",
76+
"output_type": "stream",
77+
"text": [
78+
"1\n",
79+
"2\n",
80+
"3\n",
81+
"4\n"
82+
]
83+
}
84+
],
85+
"source": [
86+
"from array import *\n",
87+
"\n",
88+
"array1 = array('i', [1,2,3,4])\n",
89+
"for x in array1:\n",
90+
" print(x)"
91+
]
92+
},
93+
{
94+
"cell_type": "markdown",
95+
"metadata": {},
96+
"source": [
97+
"#### Accessing Array Element"
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": 4,
103+
"metadata": {
104+
"ExecuteTime": {
105+
"end_time": "2019-05-23T07:07:57.070395Z",
106+
"start_time": "2019-05-23T07:07:57.063666Z"
107+
}
108+
},
109+
"outputs": [
110+
{
111+
"name": "stdout",
112+
"output_type": "stream",
113+
"text": [
114+
"3\n",
115+
"4\n"
116+
]
117+
}
118+
],
119+
"source": [
120+
"from array import *\n",
121+
"\n",
122+
"array1 = array('i', [1,2,3,4])\n",
123+
"\n",
124+
"print(array1[2])\n",
125+
"print(array1[-1])"
126+
]
127+
},
128+
{
129+
"cell_type": "markdown",
130+
"metadata": {},
131+
"source": [
132+
"#### Insertion Operation"
133+
]
134+
},
135+
{
136+
"cell_type": "code",
137+
"execution_count": 5,
138+
"metadata": {
139+
"ExecuteTime": {
140+
"end_time": "2019-05-23T07:09:54.352372Z",
141+
"start_time": "2019-05-23T07:09:54.346697Z"
142+
}
143+
},
144+
"outputs": [
145+
{
146+
"name": "stdout",
147+
"output_type": "stream",
148+
"text": [
149+
"array('i', [1, 44, 2, 3, 4, 5, 6])\n"
150+
]
151+
}
152+
],
153+
"source": [
154+
"from array import *\n",
155+
"\n",
156+
"array1 = array('i', [1,2,3,4,5,6])\n",
157+
"\n",
158+
"array1.insert(1, 44)\n",
159+
"print(array1)"
160+
]
161+
},
162+
{
163+
"cell_type": "markdown",
164+
"metadata": {},
165+
"source": [
166+
"#### Deletion Operation"
167+
]
168+
},
169+
{
170+
"cell_type": "code",
171+
"execution_count": 6,
172+
"metadata": {
173+
"ExecuteTime": {
174+
"end_time": "2019-05-23T07:10:58.372893Z",
175+
"start_time": "2019-05-23T07:10:58.366593Z"
176+
}
177+
},
178+
"outputs": [
179+
{
180+
"name": "stdout",
181+
"output_type": "stream",
182+
"text": [
183+
"array('i', [1, 2, 3, 5, 10, 11, 100])\n"
184+
]
185+
}
186+
],
187+
"source": [
188+
"from array import *\n",
189+
"\n",
190+
"array1 = array('i', [1,2,3,4,5,10,11,100])\n",
191+
"\n",
192+
"array1.remove(4)\n",
193+
"print(array1)"
194+
]
195+
},
196+
{
197+
"cell_type": "markdown",
198+
"metadata": {},
199+
"source": [
200+
"#### Search Operation"
201+
]
202+
},
203+
{
204+
"cell_type": "code",
205+
"execution_count": 7,
206+
"metadata": {
207+
"ExecuteTime": {
208+
"end_time": "2019-05-23T07:12:00.675918Z",
209+
"start_time": "2019-05-23T07:12:00.668458Z"
210+
}
211+
},
212+
"outputs": [
213+
{
214+
"name": "stdout",
215+
"output_type": "stream",
216+
"text": [
217+
"3\n"
218+
]
219+
}
220+
],
221+
"source": [
222+
"from array import *\n",
223+
"\n",
224+
"array1 = array('i', [1,2,3,4,5])\n",
225+
"\n",
226+
"print(array1.index(4))"
227+
]
228+
},
229+
{
230+
"cell_type": "markdown",
231+
"metadata": {},
232+
"source": [
233+
"#### Update Operation"
234+
]
235+
},
236+
{
237+
"cell_type": "code",
238+
"execution_count": 9,
239+
"metadata": {
240+
"ExecuteTime": {
241+
"end_time": "2019-05-23T07:13:06.729343Z",
242+
"start_time": "2019-05-23T07:13:06.722047Z"
243+
}
244+
},
245+
"outputs": [
246+
{
247+
"name": "stdout",
248+
"output_type": "stream",
249+
"text": [
250+
"array('i', [1, 2, 100, 4, 5])\n"
251+
]
252+
}
253+
],
254+
"source": [
255+
"from array import *\n",
256+
"\n",
257+
"array1 = array('i', [1,2,3,4,5])\n",
258+
"\n",
259+
"array1[2] = 100\n",
260+
"print(array1)"
261+
]
262+
}
263+
],
264+
"metadata": {
265+
"kernelspec": {
266+
"display_name": "python pratice",
267+
"language": "python",
268+
"name": "env_name"
269+
},
270+
"language_info": {
271+
"codemirror_mode": {
272+
"name": "ipython",
273+
"version": 3
274+
},
275+
"file_extension": ".py",
276+
"mimetype": "text/x-python",
277+
"name": "python",
278+
"nbconvert_exporter": "python",
279+
"pygments_lexer": "ipython3",
280+
"version": "3.7.1"
281+
},
282+
"toc": {
283+
"base_numbering": 1,
284+
"nav_menu": {},
285+
"number_sections": true,
286+
"sideBar": true,
287+
"skip_h1_title": false,
288+
"title_cell": "Table of Contents",
289+
"title_sidebar": "Contents",
290+
"toc_cell": false,
291+
"toc_position": {},
292+
"toc_section_display": true,
293+
"toc_window_display": false
294+
}
295+
},
296+
"nbformat": 4,
297+
"nbformat_minor": 2
298+
}

0 commit comments

Comments
 (0)