Skip to content
Snippets Groups Projects
Commit 3f5f39c7 authored by Dominik Zobel's avatar Dominik Zobel Committed by Tobias Koelling
Browse files

More compact and interactive sorting slides

parent b46ccbd5
No related branches found
No related tags found
1 merge request!24complexity lecture
......@@ -57,23 +57,43 @@ Tree[^1] $\mathcal{O}(\log{n})$ $\mathcal{O}(\log{n})$
* bisect (?) (ref to `git bisect`)
## Bubble Sort (1/2)
## Bubble Sort (1/2) {.leftalign}
:::{.smaller}
:::{.r-stack}
![](static/bubble_sort01.png){.fragment fragment-index=1}
![](static/bubble_sort02.png){.fragment fragment-index=2}
![](static/bubble_sort03.png){.fragment fragment-index=3}
![](static/bubble_sort04.png){.fragment fragment-index=4}
:::
:::{.fragment fragment-index=1}
1. Array which has $n$ entries
- ![](static/bubble_sort01.png)
Array which has $n$ entries
:::
:::{.fragment fragment-index=2}
- ![](static/bubble_sort02.png)
Comparing first elements. Switch elements if left element is greater than right one
2. Comparing first elements. Switch elements if left element is greater than right one
- ![](static/bubble_sort03.png)
Continue pairwise comparison until last elements
:::
- ![](static/bubble_sort04.png)
Now last element is greatest in array
:::{.fragment fragment-index=3}
- Keep repeating with $n-1$, $n-2$, ... entries until everything is sorted
3. Continue pairwise comparison until last elements
:::
:::{.fragment fragment-index=4}
4. Keep repeating with $n-1$, $n-2$, ... entries until everything is sorted
:::
......@@ -95,24 +115,55 @@ Bubble_Sort(testvec)
```
## Merge Sort (1/3)
## Merge Sort (1/3) {.leftalign}
:::{.smaller}
- ![](static/merge_sort01.png)
Array which has $n$ entries
:::{.r-stack}
![](static/merge_sort01.png){.fragment fragment-index=1}
- ![](static/merge_sort02.png)
Iteratively divide into groups until each group only has one element
![](static/merge_sort02.png){.fragment fragment-index=2}
- ![](static/merge_sort03.png)
![](static/merge_sort04.png)
Compare and sort elements of two neighboring groups into one bigger group
![](static/merge_sort03.png){.fragment fragment-index=3}
- Keep repeating previous step until there is only one group with the full array
![](static/merge_sort04.png){.fragment fragment-index=4}
![](static/merge_sort05.png){.fragment fragment-index=5}
:::
:::{.fragment fragment-index=1}
1. Array which has $n$ entries
:::
:::{.fragment fragment-index=2}
2. Iteratively divide elements into groups
:::
:::{.fragment fragment-index=3}
3. Compare and sort elements of two neighboring groups
:::
:::{.fragment fragment-index=4}
4. Save sorted elements into group containing both
:::
:::{.fragment fragment-index=5}
5. Keep repeating step 3 and 4 until there is only one group with the full array
:::
## Merge Sort (2/3)
:::{.smaller}
......
lectures/complexity/static/bubble_sort04.png

10.4 KiB | W: | H:

lectures/complexity/static/bubble_sort04.png

13.1 KiB | W: | H:

lectures/complexity/static/bubble_sort04.png
lectures/complexity/static/bubble_sort04.png
lectures/complexity/static/bubble_sort04.png
lectures/complexity/static/bubble_sort04.png
  • 2-up
  • Swipe
  • Onion skin
lectures/complexity/static/merge_sort01.png

9.19 KiB | W: | H:

lectures/complexity/static/merge_sort01.png

9.23 KiB | W: | H:

lectures/complexity/static/merge_sort01.png
lectures/complexity/static/merge_sort01.png
lectures/complexity/static/merge_sort01.png
lectures/complexity/static/merge_sort01.png
  • 2-up
  • Swipe
  • Onion skin
lectures/complexity/static/merge_sort02.png

15.6 KiB | W: | H:

lectures/complexity/static/merge_sort02.png

15.6 KiB | W: | H:

lectures/complexity/static/merge_sort02.png
lectures/complexity/static/merge_sort02.png
lectures/complexity/static/merge_sort02.png
lectures/complexity/static/merge_sort02.png
  • 2-up
  • Swipe
  • Onion skin
lectures/complexity/static/merge_sort04.png

10.3 KiB | W: | H:

lectures/complexity/static/merge_sort04.png

10.3 KiB | W: | H:

lectures/complexity/static/merge_sort04.png
lectures/complexity/static/merge_sort04.png
lectures/complexity/static/merge_sort04.png
lectures/complexity/static/merge_sort04.png
  • 2-up
  • Swipe
  • Onion skin
lectures/complexity/static/merge_sort05.png

12.2 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment