Forrest Yu's articles

forrest.yu_at_gmail_dot_com

mixed English-Chinese monospace font in Emacs

I like the width of English monospace font to be half a Chinese character.

Convert your stuff in Linux

You will learn how to:

I migrated my blogs (wordpress) to WebFaction from Bluehost

My blogs (yuyuan.org and forrestyu.org) were hosted in Bluehost (sponsored by Joe Guo). Now that I have bought my own hosting service from WebFaction, it's time to do some migration. In this article are what I did. You can use it as a step-by-step HOWTO.

Math in reStructuredText

In this article I compare several solutions to writing math in reStructuredText and show how to write a custom filter to facilitate the use in a Django project.

Math sample:

When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are

\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}\]

How to alter a sqlite table in Django

There are several ways to alter a table in the sqlite database of your Django project, here I'm introducing a most straighforward way. It may seem dirty, but it works well, and does not need any third-party tool.

An example of attacking yourself

This article begins with a story like this: you remember your password is one of the phrases you usually use as passwords but you are not sure which one it is.

Red-Black Tree Tutorial

Red-Black Tree Sample

Red-Black Tree is tricky. If you feel so, this tutorial may help. While reading, please forget what you have learned temporarily, follow this tutorial, then go back to your Red-Black textbook. You'll find the RBtree is not that difficult to grasp.

How to traverse a binary tree without using any stack

There is an exercise (ex.2.3.1-21) in TAOCP vol.1:

21. [33] Design an algorithm that traverses an unthreaded binary tree in inorder without using any auxiliary stack. It is permissible to alter the LLINK and RLINK fields of the tree nodes in any manner whatsoever during the traversal, subject only to the condition that the binary tree should have the conventional representation illustrated in (2) both before and after your algorithm has traversed the tree. No other bits in the tree nodes are available for temporary storage.
TAOCP 2.3.1-(2)

(from TAOCP 2.3.1)

In the answer given by Prof. Knuth, an algorithm by Joseph M. Morris [Inf. Proc. Letters 9 (1979), 197-200] is introduced. The algorithm is very interesting. I'd like to show you how it works here.

Knuth on programming

Let's listen to the master.

Boothroyd Algorithm

How would you revert all edges in a graph like this:

revert all edges

(Each \(k\rightarrow X[k]\) is an edge.)

Well, there are many ways to do this. Boothroyd algorithm is an interesting one of them. Prof. Knuth said it is "deucedly clever". Let's study it and see how clever it is.

Generating Function Tutorial

Everybody knows Fibonacci numbers. It can be defined as:

\[\begin{align} F_{n}=\begin{cases} 0 & n=0\\ 1 & n=1\\ F_{n-1}+F_{n-2} & n>1 \end{cases} \end{align}\]

But do you know what the closed form of \(F_n\) is? Do you know how to find it out?

Generating function is the tool to solve questions like this. In this tutorial I'll show you how generating function can be applied to get the closed-form solution.

Interesting Binomial Coefficients

\[\binom{n}{k} = \frac{n(n-1)\ldots(n-k+1)}{k(k-1)\ldots(1)}\]
\[\]

Binomial coefficients have a lot of interesting properties. Here I'll show you, with the help of a Pascal's triangle, what is hidden behind the formulas.

A short introduction to my books

My books:


back