Text Justification

The Problem:

Sort Colors


Check Soduku Solution

The objective of Soduku game is to fill a \(9 \times 9\) grid with digits so that each column, each row, and each of the nine \(3 \times 3\) sub-grids that compose the grid (also called “boxes”, “blocks”, “regions”, or “sub-squares”) contains all of the digits from 1 to 9. A solved Soduku game is like:

Least Recently Used(LRU) Cache

According to LeetCode:

Binary Tree Operations(I)

This is the first article on binary tree operations. For other topics on binary tree, please refer to:

Action Recognition with Fisher Vectors

This is a summary of doing human action recognition using Fisher Vector with (Improved) Dense Trjectory Features(DTF, http://lear.inrialpes.fr/~wang/improved_trajectories) and STIP features(http://crcv.ucf.edu/ICCV13-Action-Workshop/download.html) on UCF 101 dataset(http://crcv.ucf.edu/data/UCF101.php). In the STIP features, two low-level visual features HOG and HOF are integrated, with dimensions 72 and 90 respectively. The (improved) DTF employ more features(TR, HOG, HOF and MBHx/MBHy) with longer dimensions.

Implementing Inclusion Property with SimpleScalar

  1. Inclusion Property
  2. Code Change
  3. Experiments
  4. Conclusion

How To Install Jekyll in Mac OSX Mavericks

  1. Procedure of installing Jekyll in Mac OS X

  2. Install Xcode Command line tools: http://stackoverflow.com/questions/9329243/xcode-4-4-and-later-install-command-line-tools

  3. Clang error during install Jekyll

clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [redcarpet.bundle] Error 1


C++ Code to Print Pascal Triangle

Printing Pascal Triangle seems like an easy problem, however, it is not that easy to print a good-looking Pascal Triangle. 

To print the Pascal Triangle, for each line, first print spaces to the left of numbers, and then print digit numbers.

To calculate Pascal numbers, two assays can be used: one array to store numbers of above line, the other array to store numbers of this line. The first line has 1 number(1), the second lien has 2 numbers(1 1), the third line has three numbers(1 2 1) and so on.

To make the Pascal Triangle more readable, print spaces between two neighbor  numbers in the same line.

// Pascal triangle
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;

const int WIDTH=7;
int main()
	int* oldarr=new int[WIDTH]; // store numbers of above row
	int* newarr=new int[WIDTH]; // store numbers of current row

	for(int i=0;i<WIDTH;++i) // cntrol row counting
		for(int j=0;j<WIDTH-i-1;++j) // left space
			cout<<setw(2)<<" ";

		// set default boundary numbers

			for(int k=1;k<i;++k)

		// Print the middle part
		int idx=0;
		int flag=(WIDTH-i-1)%2;
		for(int j=WIDTH-i-1;j<WIDTH+i;++j)
			} else {
				cout<<setw(2)<<" ";
		//for(int j=WIDTH+i;j<WIDTH;++j) // Print right space, if you like
		//	cout<<setw(4)<<" ";


	delete [] oldarr;
	delete [] newarr;

	return 0;

The output looks like:

           1   1
         1   2   1
       1   3   3   1
     1   4   6   4   1
   1   5  10  10   5   1
 1   6  15  20  15   6   1

BACI Simple Install and Compile Guide

This is a guideline for a course of this semester, for which I am serving as a teaching assistant. I publish it here in hope that it can also help someone else who want to use BACI.

Install BACI

  1. Go to http://inside.mines.edu/~tcamp/baci/baci_index.html#Obtain and download BACI executables:

  2. For windows user, after download and unzip the BACI DOS executables, please put the folder called badosxe directly under the C:\ drive so it’s easy to find it. You can do all your BACI work inside this directory.

    • If your badosxe folder is C:\badosxe, then in your command prompt (cmd) your path should be C:\badosxe> bacc <file_name> .

  3. For Linux user, after download and gunzip the BACI executables, please make sure to add balnxxe into your PATH: export PATH=$PATH:/path/to/your/balnxxe (You also can add this line into $HOME/.profile, so that this command will be executed every time you login).

  4. If you want to use jBACI(BACI with a graphical IDE), please go to https://code.google.com/p/jbaci/downloads/list, and choose the jbaci-1.4.6.binaries.zip. Unfortunately, currently jBACI is only available for Windows.

  5. If you want to use BACI on the Eustis server, please download Linux version BACI first, gunzip it and then upload them into your home folder of Eustis server. Please remember to add BACI executables into your PATH(as step 3).

  6. NetBeans + BACI plugin is the best choice for people who prefer a modern IDE or MAC users. You need to install NetBeans first, and then follow the guide of setting up BaciBeans. NetBeans is a cross-platform IDE, so it can work on all operating systems that have Java JDK installed.

Compile and run BACI program

  1. Make sure that bacc is in your PATH, or put your BACI program in the same folder of bacc. Note the .cm extension. This is the extension that identifies BACI source files to the BACI compiler.

  2. Invoke the compile command bacc your_prog.cm. This creates an object file called your_prog.pco and also a listing file called your_prog.lst.

  3. Invoke the interpreter through the command bainterp your_prog (please note, there is no suffix here) to execute your code. bainterp has an option -t that will display the order in which processes terminate within the program.

Verify the installation of BACI

  1. Download example.cm.

  2. Run command  bacc example.cm. If you see following outputs, then the example.cm is successfully compiled:

bo@HEC-2GQFTK1:~/Documents/BACI$ bacc example.cm

Pcode and tables are stored in example.pco

Compilation listing is stored in example.lst

  1. Execute command  bainterp -t example. If you get following message, then bainterp runs correctly.

bo@HEC-2GQFTK1:~/Documents/BACI$ bainterp -t example

Source file: example.cm  Wed Jan 22 15:16:12 2014

Executing PCODE ...

before v(count) value of count is 0

process 2 increment,  procedure increment ended

before p(count) value of count is 1

process 1 decrement,  procedure decrement ended

More Options of BACI Compiler

A BACI source file using the C-- compiler should use a .cm suffix. To execute a program in BACI, there are two steps:

1. Compile a ".cm" file to obtain a PCODE file (.pco)

Usage: bacc [optional_flags] source_filename


-h show this help

-c make a .pob object file for subsequent linkingInterpret a PCODE file (.pco) to execute the program

2. Usage bainterp [optional_flags] pcode_filename


-d enter the debugger, single step, set breakpoints

-e show the activation record (AR) on entry to each process

-x show the AR on exit from each process

-t announce process termination

-h show this help

-p show PCODE instructions as they are executed

There is a shell script, baccint, that will call the compiler and then call the interpreter for you. It passes the options that you give it along to the interpreter. If you are using the Pascal compiler syntax, then the source file should be with a .pm suffix, and you compile the program with the bapas compiler.