Skip to content

Commit 554b9e1

Browse files
committed
Execute all notebooks in order to see verbose examples
1 parent a15933f commit 554b9e1

File tree

12 files changed

+11320
-296
lines changed

12 files changed

+11320
-296
lines changed

Seminars/sem_01/playground_01.ipynb

Lines changed: 255 additions & 61 deletions
Large diffs are not rendered by default.

Seminars/sem_02/playground_02.ipynb

Lines changed: 10314 additions & 37 deletions
Large diffs are not rendered by default.

Seminars/sem_03/playground_03.ipynb

Lines changed: 436 additions & 49 deletions
Large diffs are not rendered by default.

Seminars/sem_04/playground_04.ipynb

Lines changed: 198 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@
2323
},
2424
{
2525
"cell_type": "code",
26-
"execution_count": null,
26+
"execution_count": 1,
2727
"metadata": {},
28-
"outputs": [],
28+
"outputs": [
29+
{
30+
"name": "stdout",
31+
"output_type": "stream",
32+
"text": [
33+
"Found number 6 at index: 4\n"
34+
]
35+
}
36+
],
2937
"source": [
3038
"def linear_search(arr, X):\n",
3139
" for i in range(len(arr)):\n",
@@ -50,9 +58,17 @@
5058
},
5159
{
5260
"cell_type": "code",
53-
"execution_count": null,
61+
"execution_count": 2,
5462
"metadata": {},
55-
"outputs": [],
63+
"outputs": [
64+
{
65+
"name": "stdout",
66+
"output_type": "stream",
67+
"text": [
68+
"Found number 6 at index: 4\n"
69+
]
70+
}
71+
],
5672
"source": [
5773
"def linear_search(sequence, target):\n",
5874
" for index, item in enumerate(sequence):\n",
@@ -83,9 +99,17 @@
8399
},
84100
{
85101
"cell_type": "code",
86-
"execution_count": null,
102+
"execution_count": 3,
87103
"metadata": {},
88-
"outputs": [],
104+
"outputs": [
105+
{
106+
"name": "stdout",
107+
"output_type": "stream",
108+
"text": [
109+
"Found number 60 at index: 5\n"
110+
]
111+
}
112+
],
89113
"source": [
90114
"def binary_search(arr, X):\n",
91115
" left = 0\n",
@@ -127,9 +151,23 @@
127151
},
128152
{
129153
"cell_type": "code",
130-
"execution_count": null,
154+
"execution_count": 4,
131155
"metadata": {},
132-
"outputs": [],
156+
"outputs": [
157+
{
158+
"name": "stdout",
159+
"output_type": "stream",
160+
"text": [
161+
"Leftmost number 10 is at index: 0\n",
162+
"Leftmost number 20 is at index: 0\n",
163+
"Leftmost number 30 is at index: 2\n",
164+
"Leftmost number 40 is at index: 3\n",
165+
"Leftmost number 50 is at index: 7\n",
166+
"Leftmost number 60 is at index: 7\n",
167+
"Leftmost number 70 is at index: 9\n"
168+
]
169+
}
170+
],
133171
"source": [
134172
"def binary_search_leftmost(arr, X):\n",
135173
" left = 0\n",
@@ -165,9 +203,23 @@
165203
},
166204
{
167205
"cell_type": "code",
168-
"execution_count": null,
206+
"execution_count": 5,
169207
"metadata": {},
170-
"outputs": [],
208+
"outputs": [
209+
{
210+
"name": "stdout",
211+
"output_type": "stream",
212+
"text": [
213+
"X = 40, arr[mid=4] = 40, Xi = 9 [20, 20, 30, 40, 40, 40, 40, 60, 60, 60]\n",
214+
"New Xi is 4\n",
215+
"X = 40, arr[mid=1] = 20, Xi = 4 [20, 20, 30, 40]\n",
216+
"X = 40, arr[mid=2] = 30, Xi = 4 [30, 40]\n",
217+
"X = 40, arr[mid=3] = 40, Xi = 4 [40]\n",
218+
"New Xi is 3\n",
219+
"Leftmost number 40 is at index: 3\n"
220+
]
221+
}
222+
],
171223
"source": [
172224
"def binary_search_leftmost(arr, X):\n",
173225
" left = 0\n",
@@ -204,9 +256,23 @@
204256
},
205257
{
206258
"cell_type": "code",
207-
"execution_count": null,
259+
"execution_count": 6,
208260
"metadata": {},
209-
"outputs": [],
261+
"outputs": [
262+
{
263+
"name": "stdout",
264+
"output_type": "stream",
265+
"text": [
266+
"Rightmost number 10 is at index: 0\n",
267+
"Rightmost number 20 is at index: 1\n",
268+
"Rightmost number 30 is at index: 2\n",
269+
"Rightmost number 40 is at index: 6\n",
270+
"Rightmost number 50 is at index: 6\n",
271+
"Rightmost number 60 is at index: 9\n",
272+
"Rightmost number 70 is at index: 9\n"
273+
]
274+
}
275+
],
210276
"source": [
211277
"def binary_search_rightmost(arr, X):\n",
212278
" left = 0\n",
@@ -242,9 +308,24 @@
242308
},
243309
{
244310
"cell_type": "code",
245-
"execution_count": null,
311+
"execution_count": 7,
246312
"metadata": {},
247-
"outputs": [],
313+
"outputs": [
314+
{
315+
"name": "stdout",
316+
"output_type": "stream",
317+
"text": [
318+
"X = 40, arr[mid=4] = 40, Xi = 0 [20, 20, 30, 40, 40, 40, 40, 60, 60, 60]\n",
319+
"New Xi is 4\n",
320+
"X = 40, arr[mid=7] = 60, Xi = 4 [40, 40, 60, 60, 60]\n",
321+
"X = 40, arr[mid=5] = 40, Xi = 4 [40, 40]\n",
322+
"New Xi is 5\n",
323+
"X = 40, arr[mid=6] = 40, Xi = 5 [40]\n",
324+
"New Xi is 6\n",
325+
"Rightmost number 40 is at index: 6\n"
326+
]
327+
}
328+
],
248329
"source": [
249330
"def binary_search_rightmost(arr, X):\n",
250331
" left = 0\n",
@@ -281,9 +362,17 @@
281362
},
282363
{
283364
"cell_type": "code",
284-
"execution_count": null,
365+
"execution_count": 8,
285366
"metadata": {},
286-
"outputs": [],
367+
"outputs": [
368+
{
369+
"name": "stdout",
370+
"output_type": "stream",
371+
"text": [
372+
"Number 40 is at index: 4\n"
373+
]
374+
}
375+
],
287376
"source": [
288377
"def binary_search_recursive(arr, X, left, right):\n",
289378
" if left <= right:\n",
@@ -321,9 +410,17 @@
321410
},
322411
{
323412
"cell_type": "code",
324-
"execution_count": null,
413+
"execution_count": 9,
325414
"metadata": {},
326-
"outputs": [],
415+
"outputs": [
416+
{
417+
"name": "stdout",
418+
"output_type": "stream",
419+
"text": [
420+
"Number 60 is at index: 5\n"
421+
]
422+
}
423+
],
327424
"source": [
328425
"def ternarySearch(arr, key, l, r):\n",
329426
" if r >= l:\n",
@@ -360,9 +457,21 @@
360457
},
361458
{
362459
"cell_type": "code",
363-
"execution_count": null,
460+
"execution_count": 10,
364461
"metadata": {},
365-
"outputs": [],
462+
"outputs": [
463+
{
464+
"name": "stdout",
465+
"output_type": "stream",
466+
"text": [
467+
"arr[mid1=33] = 33, arr[mid2=66] = 66 [0, 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]\n",
468+
"arr[mid1=44] = 44, arr[mid2=55] = 55 [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]\n",
469+
"arr[mid1=59] = 59, arr[mid2=62] = 62 [56, 57, 58, 59, 60, 61, 62, 63, 64, 65]\n",
470+
"arr[mid1=60] = 60, arr[mid2=61] = 61 [60, 61]\n",
471+
"Number 60 is at index: 60\n"
472+
]
473+
}
474+
],
366475
"source": [
367476
"def ternarySearch(arr, key, l, r):\n",
368477
" if r >= l:\n",
@@ -410,9 +519,17 @@
410519
},
411520
{
412521
"cell_type": "code",
413-
"execution_count": null,
522+
"execution_count": 11,
414523
"metadata": {},
415-
"outputs": [],
524+
"outputs": [
525+
{
526+
"name": "stdout",
527+
"output_type": "stream",
528+
"text": [
529+
"Number 40 is at index: 3\n"
530+
]
531+
}
532+
],
416533
"source": [
417534
"import math\n",
418535
"\n",
@@ -455,9 +572,28 @@
455572
},
456573
{
457574
"cell_type": "code",
458-
"execution_count": null,
575+
"execution_count": 12,
459576
"metadata": {},
460-
"outputs": [],
577+
"outputs": [
578+
{
579+
"name": "stdout",
580+
"output_type": "stream",
581+
"text": [
582+
"[0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]\n",
583+
"Len is 34, blocksize is: 5\n",
584+
"Number on step 5: 12\n",
585+
"Number on step 10: 27\n",
586+
"Number on step 15: 42\n",
587+
"Number on step 20: 57\n",
588+
"Number on last step 25: 72\n",
589+
"Interval is: [60, 72)\n",
590+
"Linear searching: 60\n",
591+
"Linear searching: 63\n",
592+
"End of linear searching on number: 66\n",
593+
"Number 66 is at index: 22\n"
594+
]
595+
}
596+
],
461597
"source": [
462598
"import math\n",
463599
"\n",
@@ -519,9 +655,17 @@
519655
},
520656
{
521657
"cell_type": "code",
522-
"execution_count": null,
658+
"execution_count": 13,
523659
"metadata": {},
524-
"outputs": [],
660+
"outputs": [
661+
{
662+
"name": "stdout",
663+
"output_type": "stream",
664+
"text": [
665+
"Number 60 is at index: 5\n"
666+
]
667+
}
668+
],
525669
"source": [
526670
"def binary_search_recursive(arr, X, left, right):\n",
527671
" if left <= right:\n",
@@ -564,9 +708,26 @@
564708
},
565709
{
566710
"cell_type": "code",
567-
"execution_count": null,
711+
"execution_count": 14,
568712
"metadata": {},
569-
"outputs": [],
713+
"outputs": [
714+
{
715+
"name": "stdout",
716+
"output_type": "stream",
717+
"text": [
718+
"20 [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]\n",
719+
"1 5\n",
720+
"2 10\n",
721+
"4 20\n",
722+
"8 40\n",
723+
"Last: 16 80\n",
724+
"Number is between indexes: 8 16\n",
725+
"Number is between: 40 80\n",
726+
"Binary searching...\n",
727+
"Number 60 is at index: 12\n"
728+
]
729+
}
730+
],
570731
"source": [
571732
"def exponential_search(arr, X):\n",
572733
" N = len(arr)\n",
@@ -614,14 +775,18 @@
614775
},
615776
{
616777
"cell_type": "code",
617-
"execution_count": 24,
778+
"execution_count": 15,
618779
"metadata": {},
619780
"outputs": [
620781
{
621-
"name": "stdout",
622-
"output_type": "stream",
623-
"text": [
624-
"f(x) = 2 x^{3} + 13 x^{2} + 3 x + 5\n"
782+
"ename": "ModuleNotFoundError",
783+
"evalue": "No module named 'latexify'",
784+
"output_type": "error",
785+
"traceback": [
786+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
787+
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
788+
"Cell \u001b[1;32mIn[15], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mlatexify\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;129m@latexify\u001b[39m\u001b[38;5;241m.\u001b[39mfunction\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mf\u001b[39m(x):\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;241m2\u001b[39m\u001b[38;5;241m*\u001b[39mx\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m3\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m13\u001b[39m\u001b[38;5;241m*\u001b[39mx\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m3\u001b[39m\u001b[38;5;241m*\u001b[39mx \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m5\u001b[39m \n",
789+
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'latexify'"
625790
]
626791
}
627792
],

0 commit comments

Comments
 (0)