Archive for 四月, 2013

Circular Doubly Linked List 双向循环链表 C++ 例子

What a circular doubly linked list looks like?   Look at Figure1, It is a circular doubly linked list have 8 nodes. If you compare it and the array in Figure2, you will find that each node in doubly linked list points to the next node and pre node in the list. Because of the way that linked lists are structured, you can easily add or remove nodes at the beginning or the end of a list, or even […]

Hash Table 哈希表 C++ 例子

What’s a Hash Table? Why we need a Hash Table?   By Using a Hash Table we can find element very quickly. For example, There are 20 random number in an array below.     It’s not a sorted array, So We can not use Binary Search to finding a number, When we need to find  118, We need 12 comparisons! Finding number like 270, 198, we need even more comparison. We change the wa […]

Binary Search Tree 二叉搜索树 C++

Definition of Binary Search Tree: 1.Every node in the left subtree must be less than the current node 2.Every node in the right subtree must be greater than the current node   Here the tree in Figure 2  is a binary search tree. Finding a data in a Binary Search Tree Look at the simple queue below When we search a number in the queue, we need average (1 + 2 + 3 + 4 + 5 + 6 + 7) / 7  =  4 compa […]

Binary Search 二分查找,二分搜索 C++

// BSearch.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; template <class T> void PrintfNum(T a[],const int& n); /** * search n in a[], return the index, if not find, return -1. */ template <class T> int BSearch(T a[],const int& length,const int& n){ int left = 0, right = length – 1; […]

.x file format 详细分析.x 文件格式

The picture below is a .X file opened by DirectX Mesh View. Today, we look at the X file’s detail information. I strongly recommand readers search “X File Format Reference” topic in DirectX SDK  documentation.       The variable-length header is compulsory and must be at the beginning of the data stream. The header contains the following data.     Type Re […]