Thursday, October 21, 2010

A thought about Russell Williams

I have to see the news about Russell Williams shocked everybody, especially recently released crimal details by court. CTV’s news called it shocking news every time. I really don’t know how to critizice him, or I should call it.

First, he is a senior office in Canadian Aire Force, commandor of an air base; second, the released details about his crimal are unbelievable crude, how cans a human being did those things?

Although, generally, death penalty may be not humane, I really can not find any reason to not treat this kind of criminal with it.

Tuesday, October 19, 2010

Binary search

In cmpt454 quiz, a problem is related to binary search. But I though it is binary search tree. Now, I need clarify these two topics.

Binary search is an “algorithm” for search an item in a sorted array.
Binary search tree is a data structure, or called ordered search tree. It left subtree is smaller than the node, and right subtree is bigger than the node. When we traverse it in in-order, its elements are retrieved by order.

The similar point is that for search an item, both running time are in O(log(n)).

Monday, October 11, 2010

Database II and modern CPU architechture

I take Database II (cmpt454) this semester, and feel the way to speed up database is very similar to modern CPU.

One of the most important issues for implementing database is that the read/write speed of disk is too slow comparing to memory read/write. Therefore, algorithms, such as B+ tree,hash index and clustered record, are solutions for disk’s tardiness.

Now we have 3 layers of cpu cache, and each layer is faster than layer, and, also, CPU caches are more speedy than memory . When we use a listed list, the efficiency is not good because it does not take the advantage of CPU cache. On the other hand, if we use an array to hold data, it should be better than listed list because array is stored in sequential block, and CPU could pre-fetch elements of array to cache.

In my point of view, algorithms for implementing database will be more popular in general software development.

Tuesday, October 5, 2010

Constant and pointers

Recently, I reviewed some basic C++ knowledge. one is qualifier CONSTANT, and another one is POINTER.

CONSTANT is a useful qualifier in team project because it will reduce the mistakes when using another’s methods, but I seldom used it in my project. I should use CONSTANT more often because it makes reuse them easier.

Using “constant” and “pointer” together make it more complicated.

1.Constant variable
2.A pointer points to a constant varaible
3.A constant pointer points to variable.
4.A constant pointer points to a contant variable

Confused? Follow is an example:

const double pi = 3.14159;
const double *const pi_ptr = π

In this case, pi_ptr is a const pointer and points to a const object.