Skip to content

Commit 2846bd9

Browse files
committed
adding codility to this repo
1 parent cef874f commit 2846bd9

File tree

145 files changed

+11381
-0
lines changed

Some content is hidden

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

145 files changed

+11381
-0
lines changed

deep-learning/AlphaPose.ipynb

Lines changed: 214 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Python Time Complexity\n",
8+
"- Docs: https://wiki.python.org/moin/TimeComplexity"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"### Rules\n",
16+
"1. Different steps get added\n",
17+
"2. You drop constants\n",
18+
" - e.g. function loops to find min and then loops again to find max, you could do one loop and find both at same time, but even tho the first is 2n, you just say O(n).\n",
19+
"3. Different inputs, Different variables, loop through a and loop through b to find the intersection, O(a * b)\n"
20+
]
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"metadata": {},
25+
"source": [
26+
"### Min, Max Function\n",
27+
"- O(n)\n",
28+
" - has to iterate over each element in the structure to get the min/max value"
29+
]
30+
},
31+
{
32+
"cell_type": "markdown",
33+
"metadata": {},
34+
"source": [
35+
"### Constant Complexity: O(1)\n",
36+
"A constant task’s run time won’t change no matter what the input value is. Consider a function that prints a value in an array.\n",
37+
"\n",
38+
"No matter which element’s value you’re asking the function to print, only one step is required. So we can say the function runs in O(1) time; its run-time does not increase. Its order of magnitude is always 1.\n",
39+
"\n",
40+
"### Linear Complexity: O(n)\n",
41+
"A linear task’s run time will vary depending on it’s input value. If you ask a function to print all the items in a 10-element array, it will require less steps to complete than it would a 10,000 element array. This is said to run at O(n); it’s run time increases at an order of magnitude proportional to n.\n",
42+
"\n",
43+
"### Quadratic Complexity: O(N²)\n",
44+
"A quadratic task requires a number of steps equal to the squaure of it’s input value. Lets look at a function that takes an array and N as it’s input values where N is the number of values in the array. If I use a nested loop both of which use N as it’s limit condition, and I ask the function to print the array’s contents, the function will perform N rounds, each round printing N lines for a total of N² print steps.\n",
45+
"\n",
46+
"Let’s look at that practically. Assume the index length N of an array is 10. If the function prints the contents of it’s array in a nested-loop, it will perform 10 rounds, each round printing 10 lines for a total of 100 print steps. This is said to run in O(N²) time; it’s total run time increases at an order of magnitude proportional to N².\n",
47+
"\n",
48+
"### Exponential: O(2^N)\n",
49+
"O(2^N) is just one example of exponential growth (among O(3^n), O(4^N), etc.). Time complexity at an exponential rate means that with each step the function performs, it’s subsequent step will take longer by an order of magnitude equivalent to a factor of N. For instance, with a function whose step-time doubles with each subsequent step, it is said to have a complexity of O(2^N). A function whose step-time triples with each iteration is said to have a complexity of O(3^N) and so on.\n",
50+
"\n",
51+
"### "
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"metadata": {},
58+
"outputs": [],
59+
"source": []
60+
}
61+
],
62+
"metadata": {
63+
"kernelspec": {
64+
"display_name": "Python 3.9",
65+
"language": "python",
66+
"name": "py39"
67+
},
68+
"language_info": {
69+
"codemirror_mode": {
70+
"name": "ipython",
71+
"version": 3
72+
},
73+
"file_extension": ".py",
74+
"mimetype": "text/x-python",
75+
"name": "python",
76+
"nbconvert_exporter": "python",
77+
"pygments_lexer": "ipython3",
78+
"version": "3.7.4"
79+
},
80+
"toc": {
81+
"base_numbering": 1,
82+
"nav_menu": {},
83+
"number_sections": false,
84+
"sideBar": true,
85+
"skip_h1_title": true,
86+
"title_cell": "Table of Contents",
87+
"title_sidebar": "Table of Contents",
88+
"toc_cell": false,
89+
"toc_position": {},
90+
"toc_section_display": true,
91+
"toc_window_display": false
92+
}
93+
},
94+
"nbformat": 4,
95+
"nbformat_minor": 4
96+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Python Time Complexity\n",
8+
"- Docs: https://wiki.python.org/moin/TimeComplexity"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"### Rules\n",
16+
"1. Different steps get added\n",
17+
"2. You drop constants\n",
18+
" - e.g. function loops to find min and then loops again to find max, you could do one loop and find both at same time, but even tho the first is 2n, you just say O(n).\n",
19+
"3. Different inputs, Different variables, loop through a and loop through b to find the intersection, O(a * b)\n"
20+
]
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"metadata": {},
25+
"source": [
26+
"### Min, Max Function\n",
27+
"- O(n)\n",
28+
" - has to iterate over each element in the structure to get the min/max value"
29+
]
30+
},
31+
{
32+
"cell_type": "markdown",
33+
"metadata": {},
34+
"source": [
35+
"### Constant Complexity: O(1)\n",
36+
"A constant task’s run time won’t change no matter what the input value is. Consider a function that prints a value in an array.\n",
37+
"\n",
38+
"No matter which element’s value you’re asking the function to print, only one step is required. So we can say the function runs in O(1) time; its run-time does not increase. Its order of magnitude is always 1.\n",
39+
"\n",
40+
"### Linear Complexity: O(n)\n",
41+
"A linear task’s run time will vary depending on it’s input value. If you ask a function to print all the items in a 10-element array, it will require less steps to complete than it would a 10,000 element array. This is said to run at O(n); it’s run time increases at an order of magnitude proportional to n.\n",
42+
"\n",
43+
"### Quadratic Complexity: O(N²)\n",
44+
"A quadratic task requires a number of steps equal to the squaure of it’s input value. Lets look at a function that takes an array and N as it’s input values where N is the number of values in the array. If I use a nested loop both of which use N as it’s limit condition, and I ask the function to print the array’s contents, the function will perform N rounds, each round printing N lines for a total of N² print steps.\n",
45+
"\n",
46+
"Let’s look at that practically. Assume the index length N of an array is 10. If the function prints the contents of it’s array in a nested-loop, it will perform 10 rounds, each round printing 10 lines for a total of 100 print steps. This is said to run in O(N²) time; it’s total run time increases at an order of magnitude proportional to N².\n",
47+
"\n",
48+
"### Exponential: O(2^N)\n",
49+
"O(2^N) is just one example of exponential growth (among O(3^n), O(4^N), etc.). Time complexity at an exponential rate means that with each step the function performs, it’s subsequent step will take longer by an order of magnitude equivalent to a factor of N. For instance, with a function whose step-time doubles with each subsequent step, it is said to have a complexity of O(2^N). A function whose step-time triples with each iteration is said to have a complexity of O(3^N) and so on.\n",
50+
"\n",
51+
"### "
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"metadata": {},
58+
"outputs": [],
59+
"source": []
60+
}
61+
],
62+
"metadata": {
63+
"kernelspec": {
64+
"display_name": "Python 3.9",
65+
"language": "python",
66+
"name": "py39"
67+
},
68+
"language_info": {
69+
"codemirror_mode": {
70+
"name": "ipython",
71+
"version": 3
72+
},
73+
"file_extension": ".py",
74+
"mimetype": "text/x-python",
75+
"name": "python",
76+
"nbconvert_exporter": "python",
77+
"pygments_lexer": "ipython3",
78+
"version": "3.7.4"
79+
},
80+
"toc": {
81+
"base_numbering": 1,
82+
"nav_menu": {},
83+
"number_sections": false,
84+
"sideBar": true,
85+
"skip_h1_title": true,
86+
"title_cell": "Table of Contents",
87+
"title_sidebar": "Table of Contents",
88+
"toc_cell": false,
89+
"toc_position": {},
90+
"toc_section_display": true,
91+
"toc_window_display": false
92+
}
93+
},
94+
"nbformat": 4,
95+
"nbformat_minor": 4
96+
}

0 commit comments

Comments
 (0)