Add positional tree notes.

c-declarations
Joshua Potter 2024-04-14 12:44:20 -06:00
parent f3b59d77f6
commit 45bcc6744c
4 changed files with 286 additions and 21 deletions

View File

@ -148,7 +148,7 @@
"_journal/2024-02-02.md": "a3b222daee8a50bce4cbac699efc7180", "_journal/2024-02-02.md": "a3b222daee8a50bce4cbac699efc7180",
"_journal/2024-02-01.md": "3aa232387d2dc662384976fd116888eb", "_journal/2024-02-01.md": "3aa232387d2dc662384976fd116888eb",
"_journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970", "_journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970",
"logic/equiv-trans.md": "1198fbea260527e7dfd17b72955f5bee", "logic/equiv-trans.md": "4de3b5412f29b080a5f9f3629db38389",
"_journal/2024-02-07.md": "8d81cd56a3b33883a7706d32e77b5889", "_journal/2024-02-07.md": "8d81cd56a3b33883a7706d32e77b5889",
"algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2", "algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2",
"algorithms/loop-invariant.md": "3b390e720f3b2a98e611b49a0bb1f5a9", "algorithms/loop-invariant.md": "3b390e720f3b2a98e611b49a0bb1f5a9",
@ -310,7 +310,7 @@
"x86-64/declarations.md": "75bc7857cf2207a40cd7f0ee056af2f2", "x86-64/declarations.md": "75bc7857cf2207a40cd7f0ee056af2f2",
"x86-64/instructions.md": "240b4ceddf174f48207ba6bed4d25246", "x86-64/instructions.md": "240b4ceddf174f48207ba6bed4d25246",
"git/refs.md": "954fc69004aa65b358ec5ce07c1435ce", "git/refs.md": "954fc69004aa65b358ec5ce07c1435ce",
"set/trees.md": "fd092c77c26d0b99b3131da6dc043edd", "set/trees.md": "0e2d146f7e952aa4575e4daa82301ecd",
"_journal/2024-03-24.md": "1974cdb9fc42c3a8bebb8ac76d4b1fd6", "_journal/2024-03-24.md": "1974cdb9fc42c3a8bebb8ac76d4b1fd6",
"_journal/2024-03/2024-03-23.md": "ad4e92cc2bf37f174a0758a0753bf69b", "_journal/2024-03/2024-03-23.md": "ad4e92cc2bf37f174a0758a0753bf69b",
"_journal/2024-03/2024-03-22.md": "a509066c9cd2df692549e89f241d7bd9", "_journal/2024-03/2024-03-22.md": "a509066c9cd2df692549e89f241d7bd9",
@ -334,13 +334,16 @@
"_journal/2024-04-06.md": "1e3e0aa30b92987e6d53d5a366963b95", "_journal/2024-04-06.md": "1e3e0aa30b92987e6d53d5a366963b95",
"_journal/2024-04/2024-04-05.md": "c829cead37580ed6ece0f98497d71147", "_journal/2024-04/2024-04-05.md": "c829cead37580ed6ece0f98497d71147",
"_journal/2024-04-11.md": "23b873dd315e716ad9ee5f107f9cfefc", "_journal/2024-04-11.md": "23b873dd315e716ad9ee5f107f9cfefc",
"_journal/2024-04/2024-04-10.md": "8ada51600e1bdafd37a5552ae67281e6", "_journal/2024-04/2024-04-10.md": "e91fe6eb3d2ef5af5a293e4f92022faa",
"_journal/2024-04/2024-04-09.md": "20eeafed43b6bc48786133c3523e1029", "_journal/2024-04/2024-04-09.md": "20eeafed43b6bc48786133c3523e1029",
"_journal/2024-04/2024-04-08.md": "764b40fc657740d024b54ddd51ffb153", "_journal/2024-04/2024-04-08.md": "764b40fc657740d024b54ddd51ffb153",
"_journal/2024-04/2024-04-07.md": "848b6c8702e799c38e4f5dc506891bf7", "_journal/2024-04/2024-04-07.md": "848b6c8702e799c38e4f5dc506891bf7",
"_journal/2024-04/2024-04-06.md": "14482b513cbe15904f1b8d81b5a143d0", "_journal/2024-04/2024-04-06.md": "14482b513cbe15904f1b8d81b5a143d0",
"_journal/2024-04-12.md": "18955288bcdacf24c3d9d4b2a5b2e6d7", "_journal/2024-04-12.md": "18955288bcdacf24c3d9d4b2a5b2e6d7",
"_journal/2024-04/2024-04-11.md": "9c248442a03080cf2942436a617edfef" "_journal/2024-04/2024-04-11.md": "5baeb12bc5cc5492af766def8f849fb4",
"_journal/2024-04-14.md": "b51ad215e566bd96617d2817484232eb",
"_journal/2024-04/2024-04-13.md": "92db6bcb162a85fb0a4afd51999b6318",
"_journal/2024-04/2024-04-12.md": "1ec32792d88d470c2d517e5caf64fd6f"
}, },
"fields_dict": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -0,0 +1,11 @@
---
title: "2024-04-14"
---
- [ ] Anki Flashcards
- [ ] KoL
- [ ] Sheet Music (10 min.)
- [ ] Go (1 Life & Death Problem)
- [ ] Korean (Read 1 Story)
- [ ] Interview Prep (1 Practice Problem)
- [ ] Log Work Hours (Max 3 hours)

View File

@ -9,3 +9,5 @@ title: "2024-04-13"
- [ ] Korean (Read 1 Story) - [ ] Korean (Read 1 Story)
- [ ] Interview Prep (1 Practice Problem) - [ ] Interview Prep (1 Practice Problem)
- [x] Log Work Hours (Max 3 hours) - [x] Log Work Hours (Max 3 hours)
* Play tested the hide-and-seek application

View File

@ -121,6 +121,8 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1711136844943--> <!--ID: 1711136844943-->
END%% END%%
## Rooted Trees
A **rooted tree** is a free tree in which one vertex is distinguished/blessed as the **root**. We call vertices of rooted trees **nodes**. A **rooted tree** is a free tree in which one vertex is distinguished/blessed as the **root**. We call vertices of rooted trees **nodes**.
Let $T$ be a rooted tree with root $r$. Any node $y$ on the simple path from $r$ to node $x$ is an **ancestor** of $x$. Likewise, $x$ is a **descendant** of $y$. If the last edge on the path from $r$ to $x$ is $\{y, x\}$, $y$ is the **parent** of $x$ and $x$ is a **child** of $y$. Nodes with the same parent are called **siblings**. Let $T$ be a rooted tree with root $r$. Any node $y$ on the simple path from $r$ to node $x$ is an **ancestor** of $x$. Likewise, $x$ is a **descendant** of $y$. If the last edge on the path from $r$ to $x$ is $\{y, x\}$, $y$ is the **parent** of $x$ and $x$ is a **child** of $y$. Nodes with the same parent are called **siblings**.
@ -596,6 +598,8 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1711136845240--> <!--ID: 1711136845240-->
END%% END%%
### Ordered Trees
An **ordered tree** is a rooted tree in which the children of each node are ordered. An **ordered tree** is a rooted tree in which the children of each node are ordered.
%%ANKI %%ANKI
@ -656,6 +660,35 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1712407152763--> <!--ID: 1712407152763-->
END%% END%%
%%ANKI
Basic
Considered as rooted trees, are the following trees the same?
![[ordered-binary-tree-cmp.png]]
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466660-->
END%%
%%ANKI
Basic
Considered as ordered trees, are the following trees the same?
![[ordered-binary-tree-cmp.png]]
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466670-->
END%%
%%ANKI
Basic
Considered as binary trees, are the following trees the same?
![[ordered-binary-tree-cmp.png]]
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466676-->
END%%
### Binary Trees
A **binary tree** $T$ is a structure defined on a finite set of nodes that either A **binary tree** $T$ is a structure defined on a finite set of nodes that either
* contains no nodes, or * contains no nodes, or
@ -780,30 +813,21 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
END%% END%%
%%ANKI %%ANKI
Basic Is a binary tree a $k$-ary tree?
Considered as rooted trees, are the following trees the same?
![[ordered-binary-tree-cmp.png]]
Back: Yes. Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466660-->
END%% END%%
%%ANKI ANKI%%
Basic Is a $k$-ary tree a positional tree?
Considered as ordered trees, are the following trees the same?
![[ordered-binary-tree-cmp.png]]
Back: Yes. Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466670-->
END%% END%%
%%ANKI ANK%%
Basic Is a positional tree a $k$-ary tree?
Considered as binary trees, are the following trees the same? Back: Not necessarily.
![[ordered-binary-tree-cmp.png]]
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466676-->
END%% END%%
%%ANKI %%ANKI
@ -815,6 +839,231 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1712409466682--> <!--ID: 1712409466682-->
END%% END%%
### Positional Trees
A **positional tree** is a rooted tree in which each child is labeled with a specific positive integer. A **$k$-ary tree** is a positional tree with at most $k$ children/labels. A binary tree is a $2$-ary tree.
A $k$-ary tree is **full** if every node has degree $0$ or $k$. A $k$-ary tree is **complete** if all leaves have the same depth and all internal nodes have degree $k$.
%%ANKI
Basic
What does it mean for a binary tree to be full?
Back: Each node has $0$ or $2$ children.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128213-->
END%%
%%ANKI
What does it mean for a binary tree to be complete?
Back: Each leaf has the same depth and all internal nodes have degree $2$.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
%%ANKI
What degrees are permitted in a full binary tree?
Back: $0$ or $2$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
%%ANKI
What degrees are permitted in a complete binary tree?
Back: $0$ or $2$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
%%ANKI
What category of rooted tree does a binary tree fall under?
Back: A positional tree or $k$-ary tree.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
%%ANKI
Basic
What distinguishes a positional tree from a $k$-ary tree?
Back: A $k$-ary tree is a positional tree in which each node has at most $k$ children.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128216-->
END%%
%%ANKI
Basic
What distinguishes positional trees from ordered trees?
Back: The same children in different positions is considered distinct in the former.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128219-->
END%%
%%ANKI
Basic
What is a positional tree?
Back: A rooted tree in which each child is labeled with a specific positive integer.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128220-->
END%%
%%ANKI
Basic
What is a $k$-ary tree?
Back: A positional tree in which each node has at most $k$ children.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128223-->
END%%
%%ANKI
Basic
Which of positional trees or $k$-ary trees are more general?
Back: The positional tree.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128225-->
END%%
%%ANKI
Basic
Which of positional trees or $k$-ary trees are more general?
Back: The positional tree.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
%%ANKI
Basic
Is a binary tree a positional tree?
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128227-->
END%%
%%ANKI
Is the concept of fullness related to positional trees or $k$-ary trees?
Back: $k$-ary trees.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
%%ANKI
Basic
Is the concept of completeness related to positional trees or $k$-ary trees?
Back: $k$-ary trees.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128229-->
END%%
%%ANKI
Basic
What does it mean for a $k$-ary tree to be full?
Back: Each node has $0$ or $k$ children.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128231-->
END%%
%%ANKI
Basic
What degrees are permitted in a full $k$-ary tree?
Back: $0$ or $k$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128233-->
END%%
%%ANKI
Basic
What degrees are permitted in a complete $k$-ary tree?
Back: $0$ or $k$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128234-->
END%%
%%ANKI
Basic
What does it mean for a $k$-ary tree to be complete?
Back: All leaves have the same depth and all internal nodes have degree $k$.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128236-->
END%%
%%ANKI
Basic
What is the degree of an internal node in a complete $k$-ary tree'?
Back: $k$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128239-->
END%%
%%ANKI
Basic
What is the degree of an external node in a complete $k$-ary tree'?
Back: $0$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128241-->
END%%
%%ANKI
Basic
How many levels exist in a rooted tree of height $h$?
Back: $h + 1$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128242-->
END%%
%%ANKI
Basic
What is the height of a rooted tree with $k$ levels?
Back: $k - 1$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128244-->
END%%
%%ANKI
Basic
What recursive definition describes the number of nodes in each levelof a complete $k$-ary tree?
Back: $a_n = k \cdot a_{n-1}$ with $a_0 = 1$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1713118128246-->
END%%
%%ANKI
Basic
What recursive definition describes the number of nodes in each level of a complete $k$-ary tree?
Back: $a_n = k \cdot a_{n-1}$ with $a_0 = 1$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1713118128248-->
END%%
%%ANKI
Basic
What closed formula details the number of nodes in a complete $k$-ary tree of height $h$?
Back: $$\frac{1 - k^h}{1 - k}$$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1713118128249-->
END%%
%%ANKI
Basic
What kind of sequence describes the number of nodes in a complete $k$-ary tree?
Back: A geometric sequence.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1713118128251-->
END%%
%%ANKI
Basic
What is the common ratio in the geometric sequence counting nodes of a complete $k$-ary tree?
Back: $k$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1713118128253-->
END%%
%%ANKI
Basic
How many nodes are in a complete binary tree of height $h$?
Back: $$\frac{1 - 2^h}{1 - 2} = 2^h - 1$$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1713118128255-->
END%%
## Bibliography ## Bibliography
* Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). * Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).