Skip to content

Commit

Permalink
typo in sorting notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Mar 31, 2020
1 parent 1807ebf commit e03aeec
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 4 deletions.
Binary file modified CS3345Syllabus.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions Lectures/.ipynb_checkpoints/Sorting Lecture-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
"3. Use another sorting algorithm on each non-empty bucket\n",
"4. Iterate over the buckets in order and put the elements back into the original array.\n",
"\n",
"We can use any other sorting algorithm in sorting each bucket. We could use insertion sort as it has been proven to be close to linear time on extremely small arrays. However you are free to use any other sorting algorithm instead: quicksort, mergesort, event bucketsort again (although is starts to become radix sort at that point). The question here is how to chose the number of buckets. The number of buckets we chose actually affects the running time of the algorithm. Worst-case is that all the elements are put into one bucket resulting in O($N^2$). While the average case is O($N + \\frac{N^2}{k} + k$) where k is the number of buckets, we get O(N) when k=n. So it would be best to create n buckets when sorting. Another question is how to we decide which element goes into which bucket. For this we will define something called a divider. There are multiple ways to define a divider, a few examples are $\\frac{max-min}{num\\_buckets}$ and $\\frac{max}{num\\_buckets}$.<br>\n",
"We can use any other sorting algorithm in sorting each bucket. We could use insertion sort as it has been proven to be close to linear time on extremely small arrays. However you are free to use any other sorting algorithm instead: quicksort, mergesort, even bucketsort again (although is starts to become radix sort at that point). The question here is how to chose the number of buckets. The number of buckets we chose actually affects the running time of the algorithm. Worst-case is that all the elements are put into one bucket resulting in O($N^2$). While the average case is O($N + \\frac{N^2}{k} + k$) where k is the number of buckets, we get O(N) when k=n. So it would be best to create n buckets when sorting. Another question is how to we decide which element goes into which bucket. For this we will define something called a divider. There are multiple ways to define a divider, a few examples are $\\frac{max-min}{num\\_buckets}$ and $\\frac{max}{num\\_buckets}$.<br>\n",
"Lets look at an implementation of bucket sort:\n",
"```python\n",
"def bucket_sort(arr, num_buckets=None):\n",
Expand All @@ -311,7 +311,7 @@
" \n",
" # assign each element to a bucket\n",
" for x in arr:\n",
" b = x // size # use // to take the floor\n",
" b = x // divider # use // to take the floor\n",
" \n",
" # if b == num_buckets then assign it to num_buckets - 1\n",
" if b == num_buckets:\n",
Expand Down
4 changes: 2 additions & 2 deletions Lectures/Sorting Lecture.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
"3. Use another sorting algorithm on each non-empty bucket\n",
"4. Iterate over the buckets in order and put the elements back into the original array.\n",
"\n",
"We can use any other sorting algorithm in sorting each bucket. We could use insertion sort as it has been proven to be close to linear time on extremely small arrays. However you are free to use any other sorting algorithm instead: quicksort, mergesort, event bucketsort again (although is starts to become radix sort at that point). The question here is how to chose the number of buckets. The number of buckets we chose actually affects the running time of the algorithm. Worst-case is that all the elements are put into one bucket resulting in O($N^2$). While the average case is O($N + \\frac{N^2}{k} + k$) where k is the number of buckets, we get O(N) when k=n. So it would be best to create n buckets when sorting. Another question is how to we decide which element goes into which bucket. For this we will define something called a divider. There are multiple ways to define a divider, a few examples are $\\frac{max-min}{num\\_buckets}$ and $\\frac{max}{num\\_buckets}$.<br>\n",
"We can use any other sorting algorithm in sorting each bucket. We could use insertion sort as it has been proven to be close to linear time on extremely small arrays. However you are free to use any other sorting algorithm instead: quicksort, mergesort, even bucketsort again (although is starts to become radix sort at that point). The question here is how to chose the number of buckets. The number of buckets we chose actually affects the running time of the algorithm. Worst-case is that all the elements are put into one bucket resulting in O($N^2$). While the average case is O($N + \\frac{N^2}{k} + k$) where k is the number of buckets, we get O(N) when k=n. So it would be best to create n buckets when sorting. Another question is how to we decide which element goes into which bucket. For this we will define something called a divider. There are multiple ways to define a divider, a few examples are $\\frac{max-min}{num\\_buckets}$ and $\\frac{max}{num\\_buckets}$.<br>\n",
"Lets look at an implementation of bucket sort:\n",
"```python\n",
"def bucket_sort(arr, num_buckets=None):\n",
Expand All @@ -311,7 +311,7 @@
" \n",
" # assign each element to a bucket\n",
" for x in arr:\n",
" b = x // size # use // to take the floor\n",
" b = x // divider # use // to take the floor\n",
" \n",
" # if b == num_buckets then assign it to num_buckets - 1\n",
" if b == num_buckets:\n",
Expand Down
Binary file added switch1941_1420.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added transcriptDCCD.pdf
Binary file not shown.

0 comments on commit e03aeec

Please sign in to comment.