Tree representation by Ciro Santilli 40 Updated 2025-07-16
This section is about ways in which you can represent a tree.
Trees are a specific type of graph, so any graph representation also provides a way to represent a tree.
Therefore this section will focus only on methods specific to tress, and which cannot be used for graphs in general.
Tree traversal by Ciro Santilli 40 Updated 2025-07-16
In principle one could talk about tree traversal of unordered trees as a number of possible traversals without a fixed order. But we won't consider that under this section, only deterministic ordered tree traversals.
This is the order in which you would want to transverse to read the chapters of a book.
Like breadth-first search, this also has the property of visiting parents before any children.
Iterative pre-order by Ciro Santilli 40 Updated 2025-07-16
This is the easiest one to do iteratively:
  • pop and visit
  • push right to stack
  • push left to stack
This is the order in which a binary search tree should be traversed for ordered output, i.e.:
This ordering makes sense for binary trees and not k-ary trees in general because if there are more than two nodes it is not clear what the top node should go in the middle of.
This is unlike pre-order depth-first search and post-order depth-first search which generalize obviously to general trees.
Iterative in-order by Ciro Santilli 40 Updated 2025-07-16
This is a bit harder than iterative pre-order: now we have to check if there is a left or right element or not:
  • (START) push current
  • if there is left:
    • move left
  • else:
    • (ELSE) pop
    • visit
    • if there is right
      • move right
      • GOTO START
    • else:
      • GOTO ELSE
The control flow can be slightly simplified if we allow NULLs: www.geeksforgeeks.org/inorder-tree-traversal-without-recursion/
Game theory by Ciro Santilli 40 Updated 2025-07-16
As mentioned at Human Compatible by Stuart J. Russell (2019), game theory can be seen as the part of artificial intelligence that deas with scenarios where multiple intelligent agents are involved.
Nash equilibrium by Ciro Santilli 40 Updated 2025-07-16
The best example to look at first is the penalty kick left right Nash equilibrium.
Then, a much more interesting example is choosing a deck of a TCG competition: Magic: The Gathering meta-based deck choice is a bimatrix game, which is the exact same, but each player has N choices rather than 2.
The next case that should be analyzed is the prisoner's dilemma.
The key idea is that:
  • imagine that the game will be played many times between two players
  • if one player always chooses one deck, the other player will adapt by choosing the anti-deck
  • therefore, the best strategy for both players, is to pick decks randomly, each with a certain probability. This type of probabilistic approach is called a mixed strategy
  • if any player deviates from the equilibrium probability, then the other player can add more of the anti-deck to the deck that the other player deviated, and gain an edge
    Therefore, using equilibrium probabilities is the optimal way to play
When taking a penalty kick in soccer, the kicker must chose left or right.
And before he kicks, the goalkeeper must also decide left or right, because there is no time to see where the ball is going.
Because the kicker is right footed however, he kicker kicks better to one side than the other. So we have four probabilities:
  • goal kick left keeper jumps left
  • goal kick right keeper jumps right
  • goal kick left keeper jumps right. Note that it is possible that this won't be a goal, even though the keeper is nowhere near the ball, as the ball might just miss the goal by a bit.
  • kick right and keeper jumps left. Analogous to above
Mathematician by Ciro Santilli 40 Updated 2025-07-16
Poet, scientists and warriors all in one? Conquerors of the useless.
A wise teacher from University of São Paulo once told the class Ciro Santilli attended an anecdote about his life:
I used to want to learn Mathematics.
But it was very hard.
So in the end, I became an engineer, and found an engineering solution to the problem, and married a Mathematician instead.
It turned out that, about 10 years later, Ciro ended up following this advice, unwittingly.
Figure 1.
xkcd 435: Fields arranged by purity
. Source.

Pinned article: Introduction to the OurBigBook Project

Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
We have two killer features:
  1. topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculus
    Articles of different users are sorted by upvote within each article page. This feature is a bit like:
    • a Wikipedia where each user can have their own version of each article
    • a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
    This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.
    Figure 1.
    Screenshot of the "Derivative" topic page
    . View it live at: ourbigbook.com/go/topic/derivative
  2. local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:
    This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
    Figure 2.
    You can publish local OurBigBook lightweight markup files to either https://OurBigBook.com or as a static website
    .
    Figure 3.
    Visual Studio Code extension installation
    .
    Figure 4.
    Visual Studio Code extension tree navigation
    .
    Figure 5.
    Web editor
    . You can also edit articles on the Web editor without installing anything locally.
    Video 3.
    Edit locally and publish demo
    . Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension.
    Video 4.
    OurBigBook Visual Studio Code extension editing and navigation demo
    . Source.
  3. https://raw.githubusercontent.com/ourbigbook/ourbigbook-media/master/feature/x/hilbert-space-arrow.png
  4. Infinitely deep tables of contents:
    Figure 6.
    Dynamic article tree with infinitely deep table of contents
    .
    Descendant pages can also show up as toplevel e.g.: ourbigbook.com/cirosantilli/chordate-subclade
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact