damdkago commited on
Commit
c9da650
1 Parent(s): 910ecce

Upload merge_sort.ipynb

Browse files
Files changed (1) hide show
  1. merge_sort.ipynb +19 -30
merge_sort.ipynb CHANGED
@@ -6,14 +6,14 @@
6
  "metadata": {},
7
  "source": [
8
  "---\n",
9
- "title: Visualising sorting of numbers using recursion in merge sort\n",
10
- "description: first viz\n",
11
  "show-code: False\n",
12
  "params: \n",
13
  " texts:\n",
14
  " input: text\n",
15
  " label: Enter numbers to sort separated by comma\n",
16
- " value: 5,2,19,3,6,100\n",
17
  "---"
18
  ]
19
  },
@@ -29,12 +29,13 @@
29
  },
30
  {
31
  "cell_type": "code",
32
- "execution_count": 56,
33
  "id": "207ffa0d-f9fa-4753-966d-40ee128dedea",
34
  "metadata": {},
35
  "outputs": [],
36
  "source": [
37
- "#app = mr.App(title=\"Visualising sorting of numbers using recursion in merge sort\", description=\"using merge sort\")"
 
38
  ]
39
  },
40
  {
@@ -52,22 +53,10 @@
52
  },
53
  {
54
  "cell_type": "code",
55
- "execution_count": 61,
56
  "id": "81f4c406-8b10-423b-947a-ab5c09cd21fe",
57
  "metadata": {},
58
- "outputs": [
59
- {
60
- "ename": "AttributeError",
61
- "evalue": "'list' object has no attribute 'split'",
62
- "output_type": "error",
63
- "traceback": [
64
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
65
- "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
66
- "Cell \u001b[1;32mIn[61], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m#texts = [int(t.value) for t in texts]\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m texts \u001b[38;5;241m=\u001b[39m \u001b[43m(\u001b[49m\u001b[43mtexts\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msplit\u001b[49m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 3\u001b[0m texts \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28mint\u001b[39m(t) \u001b[38;5;28;01mfor\u001b[39;00m t \u001b[38;5;129;01min\u001b[39;00m texts]\n",
67
- "\u001b[1;31mAttributeError\u001b[0m: 'list' object has no attribute 'split'"
68
- ]
69
- }
70
- ],
71
  "source": [
72
  "texts = (texts).split(',')\n",
73
  "texts = [int(t) for t in texts]"
@@ -75,7 +64,7 @@
75
  },
76
  {
77
  "cell_type": "code",
78
- "execution_count": 55,
79
  "id": "cb2bf025-f51b-4d1f-a2df-6848d9088e18",
80
  "metadata": {},
81
  "outputs": [
@@ -83,7 +72,7 @@
83
  "name": "stdout",
84
  "output_type": "stream",
85
  "text": [
86
- "sorting [5, 2, 19, 3, 6, 10]\n",
87
  " /\n",
88
  " [5, 2, 19]\n",
89
  " /\n",
@@ -97,27 +86,27 @@
97
  "merging [2] and [19]\n",
98
  "merging [5] and [2, 19]\n",
99
  " \\\n",
100
- " [3, 6, 10]\n",
101
  " /\n",
102
  " [3]\n",
103
  " \\\n",
104
- " [6, 10]\n",
105
  " /\n",
106
- " [6]\n",
107
  " \\\n",
108
- " [10]\n",
109
- "merging [6] and [10]\n",
110
- "merging [3] and [6, 10]\n",
111
- "merging [2, 5, 19] and [3, 6, 10]\n"
112
  ]
113
  },
114
  {
115
  "data": {
116
  "text/plain": [
117
- "[2, 3, 5, 6, 10, 19]"
118
  ]
119
  },
120
- "execution_count": 55,
121
  "metadata": {},
122
  "output_type": "execute_result"
123
  }
 
6
  "metadata": {},
7
  "source": [
8
  "---\n",
9
+ "title: Visualising sorting of numbers in merge sort\n",
10
+ "description: using recursion\n",
11
  "show-code: False\n",
12
  "params: \n",
13
  " texts:\n",
14
  " input: text\n",
15
  " label: Enter numbers to sort separated by comma\n",
16
+ " value: 5,2,19,3,100,6\n",
17
  "---"
18
  ]
19
  },
 
29
  },
30
  {
31
  "cell_type": "code",
32
+ "execution_count": 66,
33
  "id": "207ffa0d-f9fa-4753-966d-40ee128dedea",
34
  "metadata": {},
35
  "outputs": [],
36
  "source": [
37
+ "#app = mr.App(title=\"Visualising sorting of numbers using recursion in merge sort\", description=\"using merge sort\")\n",
38
+ "texts = '5,2,19,3,100,6'"
39
  ]
40
  },
41
  {
 
53
  },
54
  {
55
  "cell_type": "code",
56
+ "execution_count": 67,
57
  "id": "81f4c406-8b10-423b-947a-ab5c09cd21fe",
58
  "metadata": {},
59
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
60
  "source": [
61
  "texts = (texts).split(',')\n",
62
  "texts = [int(t) for t in texts]"
 
64
  },
65
  {
66
  "cell_type": "code",
67
+ "execution_count": 68,
68
  "id": "cb2bf025-f51b-4d1f-a2df-6848d9088e18",
69
  "metadata": {},
70
  "outputs": [
 
72
  "name": "stdout",
73
  "output_type": "stream",
74
  "text": [
75
+ "sorting [5, 2, 19, 3, 100, 6]\n",
76
  " /\n",
77
  " [5, 2, 19]\n",
78
  " /\n",
 
86
  "merging [2] and [19]\n",
87
  "merging [5] and [2, 19]\n",
88
  " \\\n",
89
+ " [3, 100, 6]\n",
90
  " /\n",
91
  " [3]\n",
92
  " \\\n",
93
+ " [100, 6]\n",
94
  " /\n",
95
+ " [100]\n",
96
  " \\\n",
97
+ " [6]\n",
98
+ "merging [100] and [6]\n",
99
+ "merging [3] and [6, 100]\n",
100
+ "merging [2, 5, 19] and [3, 6, 100]\n"
101
  ]
102
  },
103
  {
104
  "data": {
105
  "text/plain": [
106
+ "[2, 3, 5, 6, 19, 100]"
107
  ]
108
  },
109
+ "execution_count": 68,
110
  "metadata": {},
111
  "output_type": "execute_result"
112
  }