Refine notes on complete/perfect trees.

c-declarations
Joshua Potter 2024-04-25 18:01:06 -06:00
parent 262683515f
commit 9ee37c8b7d
10 changed files with 678 additions and 260 deletions

View File

@ -109,7 +109,12 @@
"rooted-tree.png", "rooted-tree.png",
"ordered-rooted-tree.png", "ordered-rooted-tree.png",
"ordered-rooted-tree-cmp.png", "ordered-rooted-tree-cmp.png",
"ordered-binary-tree-cmp.png" "ordered-binary-tree-cmp.png",
"complete-tree.png",
"nearly-complete-tree.png",
"non-nearly-complete-tree.png",
"perfect-tree.png",
"non-complete-tree.png"
], ],
"File Hashes": { "File Hashes": {
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8", "algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
@ -221,10 +226,10 @@
"_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7", "_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7",
"_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd", "_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd",
"_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b", "_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b",
"c17/strings.md": "e4012ee9a18ad44370490e375ae57f09", "c17/strings.md": "8f23005c9f8e25c72e2ac6b74b6afd7e",
"c17/index.md": "78576ee41d0185df82c59999142f4edb", "c17/index.md": "78576ee41d0185df82c59999142f4edb",
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500", "c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
"c17/declarations.md": "7556186be0678419100ee9801e85ff06", "c17/declarations.md": "7d45d1b415b66916dbb908f51d034b72",
"algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd", "algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd",
"_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4", "_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4",
"_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7", "_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7",
@ -246,7 +251,7 @@
"_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe", "_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe",
"_journal/2024-02/2024-02-29.md": "0e502a2c8baf90c2f12859b03f10b5a1", "_journal/2024-02/2024-02-29.md": "0e502a2c8baf90c2f12859b03f10b5a1",
"algebra/sequences.md": "97c217823aacf8910a1a37bde694ecfe", "algebra/sequences.md": "97c217823aacf8910a1a37bde694ecfe",
"algebra/sequences/index.md": "a15b7ce8cd040a08c7bfc8ceb6cd0525", "algebra/sequences/index.md": "06df0fd12c2367995037ec4c26c51a53",
"_journal/2024-03-02.md": "08c3cae1df0079293b47e1e9556f1ce1", "_journal/2024-03-02.md": "08c3cae1df0079293b47e1e9556f1ce1",
"_journal/2024-03/2024-03-01.md": "70da812300f284df72718dd32fc39322", "_journal/2024-03/2024-03-01.md": "70da812300f284df72718dd32fc39322",
"algebra/sequences/triangular-numbers.md": "39a84ee317d3760a2eda7279c83e921a", "algebra/sequences/triangular-numbers.md": "39a84ee317d3760a2eda7279c83e921a",
@ -310,7 +315,7 @@
"x86-64/declarations.md": "75bc7857cf2207a40cd7f0ee056af2f2", "x86-64/declarations.md": "75bc7857cf2207a40cd7f0ee056af2f2",
"x86-64/instructions.md": "d783bad8dd77748fb412715541cb844d", "x86-64/instructions.md": "d783bad8dd77748fb412715541cb844d",
"git/refs.md": "954fc69004aa65b358ec5ce07c1435ce", "git/refs.md": "954fc69004aa65b358ec5ce07c1435ce",
"set/trees.md": "4d081c258eb662e2147d1e462193e715", "set/trees.md": "6c1a245f6b25838c519f5c9bcf96c369",
"_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",
@ -362,8 +367,11 @@
"_journal/2024-04/2024-04-20.md": "043bbf73e6a317152b8fa3af03d1c57b", "_journal/2024-04/2024-04-20.md": "043bbf73e6a317152b8fa3af03d1c57b",
"_journal/2024-04-23.md": "a138b94e4c986773f30b3f2b375d3216", "_journal/2024-04-23.md": "a138b94e4c986773f30b3f2b375d3216",
"_journal/2024-04/2024-04-22.md": "1737cfe64dca349f7ea3401863555d90", "_journal/2024-04/2024-04-22.md": "1737cfe64dca349f7ea3401863555d90",
"_journal/2024-04-24.md": "388aea1c0dc33bccef57c070bf59da4d", "_journal/2024-04-24.md": "4cb04e0dea56e0b471fc0e428471a390",
"_journal/2024-04/2024-04-23.md": "010539ad366ed628faa6db384a8e4bd2" "_journal/2024-04/2024-04-23.md": "20514052da91b06b979cacb3da758837",
"_journal/2024-04-25.md": "10c98531cb90a6bc940ea7ae3342f98b",
"_journal/2024-04/2024-04-24.md": "4cb04e0dea56e0b471fc0e428471a390",
"algorithms/heaps.md": "4235ec90b6e251fc992906e0f1fe69e7"
}, },
"fields_dict": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -15,4 +15,5 @@ title: "2024-04-24"
* Explored how to limit the number of re-renders in the application. * Explored how to limit the number of re-renders in the application.
* Played around with Zustand types to get TypeScript and Immer working together (WIP). * Played around with Zustand types to get TypeScript and Immer working together (WIP).
* Read chapter 2 "Pastebin" of "Grokking the System Design Interview". * Read chapter 2 "Pastebin" of "Grokking the System Design Interview".
* Read chapter 4 of HP-16C manual. * Read chapter 4 of HP-16C manual.
* Add notes on iterating recurrence relations.

View File

@ -0,0 +1,15 @@
---
title: "2024-04-25"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] Sheet Music (10 min.)
- [ ] Go (1 Life & Death Problem)
- [ ] Korean (Read 1 Story)
- [x] Interview Prep (1 Practice Problem)
- [x] Log Work Hours (Max 3 hours)
* Talk with Mike about yesterday's "Grokking the System Interview" and "Designing Data-Intensive Applications" reading.
* Notes on nearly complete trees. Refine terminology to favor "perfect/complete" over "complete/nearly complete".
* Read Heapsort section in "Introduction to Algorithms". Still need to implement and translate into notes though.

View File

@ -171,6 +171,12 @@ END%%
## Solving Recurrence Relations ## Solving Recurrence Relations
We use three different strategies for solving recurrences:
* Telescoping
* Iteration
* Characteristic Polynomials
%%ANKI %%ANKI
Basic Basic
What is the recurrence relation for the Fibonacci sequence? What is the recurrence relation for the Fibonacci sequence?
@ -245,15 +251,14 @@ END%%
%%ANKI %%ANKI
Basic Basic
Schematically show how telescoping can be used to solve $a_n = a_{n-1} + f(n)$. Schematically show how **telescoping** can be used to solve $a_n = a_{n-1} + f(n)$.
Back: $$\begin{align*} Back: $$\begin{align*}
a_1 - a_0 & = f(1) \\ a_1 - a_0 & = f(1) \\
& \vdots \\ & \vdots \\
a_n - a_{n-1} & = f(n) \\ a_n - a_{n-1} & = f(n) \\
\hline \hline
a_n - a_0 & = \sum_{k=1}^n f(k) a_n - a_0 & = \sum_{k=1}^n f(k)
\end{align*}$$ \end{align*}$$Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713810280088--> <!--ID: 1713810280088-->
END%% END%%
@ -273,6 +278,71 @@ Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n
<!--ID: 1713810280094--> <!--ID: 1713810280094-->
END%% END%%
%%ANKI
Basic
What does it mean to solve a recurrence relation using iteration?
Back: Repeatedly expand terms, starting at the initial conditions, to discover a pattern.
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713998412589-->
END%%
%%ANKI
Basic
What is the result of "iterating" the following recursive definition twice? $$a_n = 3a_{n-1} + 2$$
Back: $$\begin{align*}
a_1 & = 3(a_0) + 2 \\
a_2 & = 3(3(a_0) + 2) + 2
\end{align*}$$
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713998412595-->
END%%
%%ANKI
Basic
Schematically show how **iteration** can be used to solve $a_n = a_{n-1} + f(n)$.
Back: $$\begin{align*}
a_1 & = a_0 + f(1) \\
& \vdots \\
a_n & = (\cdots((a_0 + f(1)) + f(2)) + \cdots) + f(n) \\
\hline
a_n & = a_0 + \sum_{k=1}^n f(k)
\end{align*}$$
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713998412597-->
END%%
%%ANKI
Basic
How fast does the number of terms grow when iterating $a_n = 3a_{n-1} + 2$?
Back: Linearly.
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713998412600-->
END%%
%%ANKI
Basic
How fast does the number of terms grow when iterating $a_n = 2a_{n-1} + 3a_{n-2}$?
Back: Exponentially (the number of terms double each iteration).
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713998412603-->
END%%
%%ANKI
Basic
Why should you avoid using iteration to solve $a_n = 2a_{n-1} + 3a_{n-2}$?
Back: The number of terms grows unwieldy very quickly.
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713998412607-->
END%%
%%ANKI
Basic
When solving recurrences, is telescoping or iteration a more general technique?
Back: Iteration.
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1713998536738-->
END%%
## Bibliography ## Bibliography
* Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf). * Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).

12
notes/algorithms/heaps.md Normal file
View File

@ -0,0 +1,12 @@
---
title: Heaps
TARGET DECK: Obsidian::STEM
FILE TAGS: algorithm::data_structure
tags:
- algorithm
- data_structure
---
## Overview
TODO

View File

@ -36,7 +36,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Text is more platform-independent than binary because it is unaffected by what two properties? Text is more platform-independent than e.g. integer encodings because it is unaffected by what two properties?
Back: Word size and byte ordering. Back: Word size and byte ordering.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1707758281270--> <!--ID: 1707758281270-->

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -1,10 +1,11 @@
--- ---
title: Trees title: Trees
TARGET DECK: Obsidian::STEM TARGET DECK: Obsidian::STEM
FILE TAGS: set::graph FILE TAGS: set::tree
tags: tags:
- graph - graph
- set - set
- tree
--- ---
## Overview ## Overview
@ -153,6 +154,22 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1711136844955--> <!--ID: 1711136844955-->
END%% 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 %%ANKI
Basic Basic
Which free trees are not considered rooted trees? Which free trees are not considered rooted trees?
@ -644,16 +661,16 @@ END%%
%%ANKI %%ANKI
Basic Basic
The following two trees are equivalent when considered as what kind of trees? The following two trees are equivalent when considered as what (most specific) kind of trees?
![[ordered-rooted-tree-cmp.png]] ![[ordered-rooted-tree-cmp.png]]
Back: Rooted/free trees. Back: Rooted trees.
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: 1712407152755--> <!--ID: 1712407152755-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
The following two trees are different when considered as what kind of trees? The following two trees are different when considered as what (most general) kind of trees?
![[ordered-rooted-tree-cmp.png]] ![[ordered-rooted-tree-cmp.png]]
Back: Ordered trees. Back: Ordered trees.
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).
@ -678,6 +695,15 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1712409466670--> <!--ID: 1712409466670-->
END%% END%%
%%ANKI
Basic
Considered as positional 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: 1714089436122-->
END%%
%%ANKI %%ANKI
Basic Basic
Considered as binary trees, are the following trees the same? Considered as binary trees, are the following trees the same?
@ -687,13 +713,541 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1712409466676--> <!--ID: 1712409466676-->
END%% END%%
### Binary Trees %%ANKI
Basic
Why are these two binary trees not the same?
![[ordered-binary-tree-cmp.png]]
Back: `5` is a left child in the first tree but a right child in the second.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466682-->
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 **perfect** if all leaves have the same depth and all internal nodes have degree $k$. A $k$-ary tree is **complete** if the last level is not filled but all leaves have the same depth and are leftmost arranged.
%%ANKI
Basic
Why aren't terms "complete/perfect" and "nearly complete/complete" quite synonymous?
Back: In the former, "perfect" trees are a subset of "complete" trees.
Reference: “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
<!--ID: 1714088438740-->
END%%
%%ANKI
Basic
What distinguishes a positional tree from a $k$-ary tree?
Back: A $k$-ary tree cannot have child with label $> k$.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128216-->
END%%
%%ANKI
Basic
Is a $k$-ary tree a positional tree?
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714089436130-->
END%%
%%ANKI
Basic
Is a positional tree a $k$-ary tree?
Back: Not necessarily.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714089436134-->
END%%
%%ANKI
Basic
What distinguishes positional trees from ordered trees?
Back: Children of the former are labeled with a distinct positive integer.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1713118128219-->
END%%
%%ANKI
Basic
Is the notion of absent children a concept in ordered trees?
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714088438749-->
END%%
%%ANKI
Basic
Is the notion of absent children a concept in positional trees?
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714088438754-->
END%%
%%ANKI
Basic
Is the notion of absent children a concept in $k$-ary trees?
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714088438759-->
END%%
%%ANKI
Basic
What is a positional tree?
Back: A rooted tree in which each child is labeled with a distinct 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 with labels greater than $k$ missing.
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 ordered trees are more general?
Back: N/A.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714088438763-->
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 perfectness 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
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: 1714088723844-->
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 perfect $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 perfect?
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 perfect $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 perfect $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
What recursive definition describes the number of nodes in each level of a perfect $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
How many nodes are in a perfect $k$-ary tree of height $h$?
Back: $$\frac{1 - k^{h+1}}{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
How many internal nodes are in a perfect $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: 1714080353459-->
END%%
%%ANKI
Basic
How many external nodes are in a perfect $k$-ary tree of height $h$?
Back: $k^h$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1714080353455-->
END%%
%%ANKI
Basic
How many nodes are on level $d$ of a perfect $k$-ary tree?
Back: $k^d$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1714080353462-->
END%%
%%ANKI
Basic
What kind of sequence describes the number of nodes in a perfect $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 of the geometric sequence used to count nodes of a perfect $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
What does it mean for a $k$-ary tree to be complete?
Back: The last level is not filled but all leaves have the same depth and are leftmost arranged.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714080353480-->
END%%
%%ANKI
Basic
How is the minimum number of nodes in a complete $k$-ary tree of height $h$ calculated in terms of perfect $k$-ary trees?
Back: As "the number of nodes in a perfect $k$-ary tree of height $h - 1$" plus $1$.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714082676018-->
END%%
%%ANKI
Basic
What is the maximum number of nodes in a complete binary tree of height $h$?
Back: $2^{h+1} - 1$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714082676014-->
END%%
%%ANKI
Basic
How is the maximum number of nodes in a complete $k$-ary tree of height $h$ calculated in terms of perfect $k$-ary trees?
Back: As "the number of nodes in a perfect $k$-ary tree of height $h$".
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714082676022-->
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
* is composed of three disjoint sets of nodes: a **root** node, a **left subtree**, and a **right subtree**. * is composed of three disjoint sets of nodes: a **root** node, a **left subtree**, and a **right subtree**.
%%ANKI
Basic
Is a binary tree a $k$-ary tree?
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714089436138-->
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).
END%%
%%ANKI
Basic
Is a binary tree an ordered tree?
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714089436144-->
END%%
%%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
Basic
What does it mean for a binary tree to be perfect?
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).
<!--ID: 1714081594570-->
END%%
%%ANKI
Basic
Is a perfect binary tree considered full?
Back: Yes.
Reference: “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
<!--ID: 1714088438720-->
END%%
%%ANKI
Basic
Is a full binary tree considered perfect?
Back: Not necessarily.
Reference: “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
<!--ID: 1714088438726-->
END%%
%%ANKI
Basic
Is a full binary tree considered complete?
Back: Not necessarily.
Reference: “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
<!--ID: 1714088438729-->
END%%
%%ANKI
Basic
Is a complete binary tree considered full?
Back: Not necessarily.
Reference: “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
<!--ID: 1714088438733-->
END%%
%%ANKI
Basic
What alternative term is sometimes used in favor of a "perfect binary tree"?
Back: A "complete binary tree".
Reference: “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
<!--ID: 1714088438737-->
END%%
%%ANKI
Basic
What alternative term is sometimes used in favor over a "complete binary tree"?
Back: Some authors may say "nearly complete" if the last level isn't completely filled.
Reference: “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
<!--ID: 1714088438744-->
END%%
%%ANKI
Basic
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).
<!--ID: 1714081594576-->
END%%
%%ANKI
Basic
What degrees are permitted in a perfect binary tree?
Back: $0$ or $2$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714081594579-->
END%%
%%ANKI
Basic
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).
<!--ID: 1714081594582-->
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
Basic
How many nodes are in a perfect binary tree of height $h$?
Back: $2^{h+1} - 1$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1713118128255-->
END%%
%%ANKI
Basic
How many internal nodes are in a perfect binary tree of height $h$?
Back: $2^h - 1$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1714080353472-->
END%%
%%ANKI
Basic
How many external nodes are in a perfect binary tree of height $h$?
Back: $2^h$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1714080353469-->
END%%
%%ANKI
Basic
How many nodes are on level $d$ of a perfect binary tree?
Back: $2^d$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1714080353465-->
END%%
%%ANKI
Basic
How does the number of internal nodes compare to the number of external nodes in a perfect binary tree?
Back: There is one more external node than internal node.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: algebra::sequence
<!--ID: 1714080353476-->
END%%
%%ANKI
Basic
Is the following a perfect binary tree?
![[perfect-tree.png]]
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714080353484-->
END%%
%%ANKI
Basic
Is the following a complete binary tree?
![[perfect-tree.png]]
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714080353488-->
END%%
%%ANKI
Basic
Is the following a full binary tree?
![[perfect-tree.png]]
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714088438768-->
END%%
%%ANKI
Basic
Is the following a perfect binary tree?
![[complete-tree.png]]
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714080353491-->
END%%
%%ANKI
Basic
Is the following a complete binary tree?
![[complete-tree.png]]
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714080353495-->
END%%
%%ANKI
Basic
Is the following a full binary tree?
![[complete-tree.png]]
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714088438773-->
END%%
%%ANKI
Basic
Is the following a perfect binary tree?
![[non-complete-tree.png]]
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714080353498-->
END%%
%%ANKI
Basic
Is the following a complete binary tree?
![[non-complete-tree.png]]
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714080353502-->
END%%
%%ANKI
Basic
Is the following a full binary tree?
![[non-complete-tree.png]]
Back: No.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714088438777-->
END%%
%%ANKI
Basic
What is the minimum number of nodes in a complete binary tree of height $h$?
Back: $2^h$
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1714082676010-->
END%%
%%ANKI %%ANKI
Basic Basic
What is the base case used in the recursive definition of a binary tree? What is the base case used in the recursive definition of a binary tree?
@ -812,249 +1366,7 @@ Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition
<!--ID: 1712409466653--> <!--ID: 1712409466653-->
END%% END%%
%%ANKI
Is a binary tree a $k$-ary tree?
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
ANKI%%
Is a $k$-ary tree a positional tree?
Back: Yes.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
ANK%%
Is a positional tree a $k$-ary tree?
Back: Not necessarily.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
END%%
%%ANKI
Basic
Why are these two binary trees not the same?
![[ordered-binary-tree-cmp.png]]
Back: `5` is a left child in the first tree but a right child in the second.
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1712409466682-->
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 $k$ labels with a potential child.
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 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
* “Binary Tree,” in _Wikipedia_, March 13, 2024, [https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees](https://en.wikipedia.org/w/index.php?title=Binary_tree&oldid=1213529508#Types_of_binary_trees).
* 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).