EM Blog

我们从未遇见, 听闻已是永别.

二叉树的遍历算法

0. 数据结构 template <typename DataType> class BTNode { DataType val_; BTNode<DataType>* lchild_; BTNode<DataType>* rchild_; }; template <typename DataType> using BTree = B...

稀疏矩阵相关算法

快速转置

1. 三元顺序表稀疏矩阵快速转置 (TC: O(n + t)) struct SparMatNode { size_t row_ = 0; // from 1 to m; size_t col_ = 0; // from 1 to n; int data_ = 0; }; using SparMat = SparMatNode*; // no header node; // ma...

排序算法模板

0. 数据结构 本文中用到的数据结构定义为 template <typename DataType> struct LNode { DataType data; LNode<DataType>* next; LNode() : next(nullptr) { memset(&data, 0, sizeof(DataType)); }; LNode...

栈法非递归化的例子

Ackermann 函数

1. 栈法求解 Ackermann 函数. unsigned int recAck(unsigned int m, unsigned int n) { if (m == 0) { return n + 1; } // now m != 0; if (n == 0) { return recAck(m - 1, 1); } return recAck(m - 1, re...

几个递归算法的例子

排列与组合

1. 递归打印 n 元集合 A 中元素的 k 元组合. // A: the set of elements to be combined; // n: the size of array A; // cache: memorizing completed part of the current combination; // len: the size of cache; // k: nu...

HTML 编程指南

1. 注释 注释形式是 <!--COMMENT--> . 2. 基本结构 2.1. 文档 HTML 文档的基本结构是 <!DOCTYPE html> <html> <head> </head> <body> <header> <...

Git 使用指南

0. 术语 未追踪文件 (untracked files): 新建的、从未加入过暂存区的文件. 未加入暂存区的文件 (unstaged files): 已加入过暂存区并被修改了的文件, 或分支中原有的并被修改了的文件. 忽略的文件 (ignored files): .gitignore 中包含的文件. 1. 安装初始化 1.1. 设置用户名和邮箱 $ git config --g...