Add sorting concepts.

pull/2/head
Joshua Potter 2024-02-02 15:38:11 -07:00
parent 0490802b91
commit d744ce4ebc
4 changed files with 84 additions and 2 deletions

View File

@ -73,8 +73,11 @@
"bash/quoting.md": "b1d8869a91001f8b22f0cdc54d806f61",
"nix/callPackage.md": "5ef6bc5d1a549c55d43ebb4d48c64427",
"nix/index.md": "dd5ddd19e95d9bdbe020c68974d77a33",
"journal/2024-02-02.md": "0df6266a5f347124df5ac795bcff51a2",
"bash/prompts.md": "64bd3cd3c2feb9edb68ad8dc5ba65a35"
"journal/2024-02-02.md": "e2acbe75752d9c39875553223e34fb0d",
"bash/prompts.md": "64bd3cd3c2feb9edb68ad8dc5ba65a35",
"algorithms/sorting/index.md": "9aedfae96c9bb86fcba6afd2800538ae",
"algorithms/sorting/insertion-sort.md": "0bdccffe868d40986aa7d0d49da918f3",
"algorithms/index.md": "1583c07edea4736db27c38fe2b6c4c31"
},
"fields_dict": {
"Basic": [

View File

@ -0,0 +1,3 @@
---
title: Algorithms
---

View File

@ -0,0 +1,54 @@
---
title: Sorting
TARGET DECK: Obsidian::STEM
FILE TAGS: algorithm sorting
tags:
- algorithm
- sorting
---
## Overview
Let $n \geq 0$ and $S = \langle a_1, a_2, \ldots, a_n \rangle$ be a sequence. The **sorting problem** refers to permuting **keys** $a_1, a_2, \ldots, a_n$ into a new sequence $\langle a_1', a_2', \ldots, a_n' \rangle$ such that $a_1' \leq a_2' \leq \cdots \leq a_n'$.
## Structural Comparison
The #Elixir documentation makes a point that there exist two types of comparisons between data types.[^structural] The first is **structural** in which comparisons are made on the underlying data structures used to describe the data types. The second is **semantic** which focuses on making the comparison with respect to what the data types represent.
```elixir
iex> 1 < :atom # structural
true
iex> Date.compare(~D[2017-03-31], ~D[2017-04-01]) # semantic
:lt
```
%%ANKI
Basic
What are the two types of comparisons made between data types?
Back: Structural and semantic.
Reference: “Kernel — Elixir v1.16.1,” accessed February 2, 2024, [https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison](https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison).
<!--ID: 1706913303147-->
END%%
%%ANKI
Basic
What is structural comparison of two data types?
Back: Comparison of the underlying data structures making up data types.
Reference: “Kernel — Elixir v1.16.1,” accessed February 2, 2024, [https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison](https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison).
<!--ID: 1706913303155-->
END%%
%%ANKI
Basic
What is semantic comparison of two data types?
Back: Comparison made with respect to what the data types represent.
Reference: “Kernel — Elixir v1.16.1,” accessed February 2, 2024, [https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison](https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison).
<!--ID: 1706913303160-->
END%%
## References
* Thomas H. Cormen et al., _Introduction to Algorithms_, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* “Kernel — Elixir v1.16.1,” accessed February 2, 2024, [https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison](https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison).
[^structural]: [Structural Comparison](https://hexdocs.pm/elixir/1.16/Kernel.html#module-structural-comparison)

View File

@ -0,0 +1,22 @@
---
title: Insertion Sort
TARGET DECK: Obsidian::STEM
FILE TAGS: algorithm sorting
tags:
- algorithm
- sorting
---
## Overview
| Property | Value |
| ------------- | ---------- |
| Best Case ||
| Worst Case ||
| Average Case ||
| Memory ||
| In place? ||
## References
* Thomas H. Cormen et al., _Introduction to Algorithms_, 3rd ed (Cambridge, Mass: MIT Press, 2009).