B树的C++源代码及测试代码
使用方法:
#include <string h>
#include <stdio h>
#include "DataTypeForBtree h"
#include "BTree h"
struct tree data
{
char tid[37];
char tname[63];
unsigned int aid;
unsigned int id;
};
class CMyDataTypeForBtree : public CDataTypeForBtree
{
public:
virtual void Print void key FILE fp
{
if NULL key || NULL fp
return;
struct tree data tr struct tree data key;
fprintf fp "%u %u %s %s n" tr >id tr >aid tr >tid tr >tname ;
}
virtual int Compare void p1 void p2
{
if NULL p1 || NULL p2
return int unsigned int 0 >> 1 ; 返回一个大点的数表示失败
struct tree data tr1 tr2;
tr1 struct tree data p1;
tr2 struct tree data p2;
if tr2 >aid tr1 >aid
{
return tr1 >aid tr2 >aid;
}
if " 0" tr1 >tid[0] && " 0" tr2 >tid[0]
{
return strcmp tr1 >tname tr2 >tname ;
}
return strcmp tr1 >tid tr2 >tid ;
}
CMyDataTypeForBtree
{
}
virtual CMyDataTypeForBtree
{
}
};
int main int argc char argv[]
{
CMyDataTypeForBtree dt new CMyDataTypeForBtree;
CBTree tree dt 5 ;
struct tree data tr[101] {{"asd" "4Hero" 1 1} {"abc" "Underworld" 1 0} {"bac" "Samantha" 1 2} {"cass" "Gelka" 1 3}
{"mark" "Clark"
B树的C++实现
用 C++ 实现的一个 B 树类,有注释,但不知道我写得能不能看明白。使用时先要从类 CDataTypeForBtree 派生一个类出来,在派生类中实现数据比较函数 Compare,数据输出函数 Print。然后在堆上创建一个数据类对象,把地址作为构造函数的参数创建树对象,下面给出一个使用示例。
#include <string.h>
#include <stdio.h>
#include "DataTypeForBtree.h"
#include "BTree.h"
struct tree_data
{
char tid[37];
char tname[63];
unsigned int aid;
unsigned int id;
};
class CMyDataTypeForBtree : public CDataTypeForBtree
{
public:
virtual void Print(void *key, FILE* fp)
{
if(NULL == key || NULL == fp)
return;
struct tree_data* tr = (struct tree_data*)key;
fprintf(fp, "%u %u %s %s\n", tr->id, tr->aid, tr->tid, tr->tname);
}
virtual int Compare(void *p1, void *p2)
{
if(NULL == p1 || NULL == p2)
return (int)(((unsigned int)(~0)) >> 1); //返回一个大点的数表示失败
struct tree_data *tr1, *tr2;
tr1 = (struct tree_data*)p1;
tr2 = (struct tree_data*)p2;
if(tr2->aid != tr1->aid)
{
return tr1->aid - tr2->aid;
}
if('\0' == tr1->tid[0] && '\0' == tr2->tid[0])
{
return strcmp(tr1->tname, tr2->tname);
}
return strcmp(tr1->tid, tr2->tid);
}
CMyDataTypeForBtree()
{
}
virtual ~CMyDataTypeForBtree()
{
}
};
int main(int argc, char* argv[])
{
CMyDataTypeForBtree *dt = new CMyDataTypeForBtree;
CBTree tree(dt, 5);
struct tree_data tr[101] = {{"asd", "4Hero", 1, 1}, {"abc", "Underworld", 1, 0}, {"bac", "Samantha", 1, 2}, {"cass", "Gelka", 1, 3},
{"mark", "Clark", 1, 4}, {"gone", "Woolfy", 1, 5}, {"word", "Production", 1, 6}, {"paper", "Jimpster", 1, 7}, {"Richie", "Hawtin", 1, 8},
{"John", "Matthias", 1, 9}, {"Lou", "Donaldson", 1, 10}, {"Lady", "Alma", 1, 11}, {"Mass", "Slick", 1, 12}, {"Clyde", "Alexander", 1, 13},
//……省略若干,省略部分在下载包里面有
{"", "I'M Not Sayin' Get 'Er Done, But Don'T Just Stand There", 11, 101},};
for(int i = 0; i < 101; i++)
{
tree.Insert((void*)(tr + i));
}
tree.DelKey((void*)(tr + 5));
tree.Traverse(NULL, NULL);
tree.DelKey((void*)(tr + 13));
tree.Traverse(NULL, NULL); //输出到标准输出,可以重定向到文件
return 0;
}
算法导论第二版-part3
算法导论第二版,(美)科曼(Cormen.T.H.)等著,潘金贵等译。不是那种只有半页的。这是29章以后的部分,三部分均免费下载。
算法导论第二版-part2
算法导论第二版,(美)科曼(Cormen.T.H.)等著,潘金贵等译。不是那种只有半页的。这是前17-28章,三部分均免费下载。
算法导论第二版-part1
算法导论第二版,(美)科曼(Cormen.T.H.)等著,潘金贵等译。不是那种只有半页的。这是前16章,三部分均免费下载。
libsvm-3.17
支持向量机源码,可在 www.csie.ntu.edu.tw/~cjlin/libsvm/ 下载到最新版本,该版本是 2013年4月更新的,3.17 版。压缩包里面有源代码和文档。以下摘自前述网站:
Introduction
LIBSVM is an integrated software for support vector classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and distribution estimation (one-class SVM). It supports multi-class classification.
Since version 2.8, it implements an SMO-type algorithm proposed in this paper:
R.-E. Fan, P.-H. Chen, and C.-J. Lin. Working set selection using second order information for training SVM. Journal of Machine Learning Research 6, 1889-1918, 2005. You can also find a pseudo code there. (how to cite LIBSVM)
Our goal is to help users from other fields to easily use SVM as a tool. LIBSVM provides a simple interface where users can easily link it with their own programs. Main features of LIBSVM include
Different SVM formulations
Efficient multi-class classification
Cross validation for model selection
Probability estimates
Various kernels (including precomputed kernel matrix)
Weighted SVM for unbalanced data
Both C++ and Java sources
GUI demonstrating SVM classification and regression
Python, R, MATLAB, Perl, Ruby, Weka, Common LISP, CLISP, Haskell, OCaml, LabVIEW, and PHP interfaces. C# .NET code and CUDA extension is available.
It's also included in some data mining environments: RapidMiner, PCP, and LIONsolver.
Automatic model selection which can generate contour of cross valiation accuracy.
集体智慧编程随书代码
集体智慧编程随书代码
├─chapter2
│ deliciousrec.py
│ pydelicious.py
│ recommendations.py
│
├─chapter3
│ blogdata.txt
│ clusters.py
│ downloadzebodata.py
│ feedlist.txt
│ generatefeedvector.py
│ Thumbs.db
│ zebo.txt
│
├─chapter4
│ nn.py
│ searchengine.py
│
├─chapter5
│ dorm.py
│ kayak.py
│ optimization.py
│ schedule.txt
│ socialnetwork.py
│
├─chapter6
│ docclass.py
│ feedfilter.py
│ python_search.xml
│ test.db
│ test1.db
│
├─chapter7
│ addresslist.txt
│ hotornot.py
│ Thumbs.db
│ treepredict.py
│ zillow.py
│
├─chapter8
│ ebaypredict.py
│ numpredict.py
│ optimization.py
│
├─chapter9
| advancedclassify.py
| agesonly.csv
| facebook.py
| matchmaker.csv
| svm.py
| svm.pyc
| svmc.pyd
|
├─chapter10
│ articles.txt
│ clusters.py
│ docclass.py
│ features.txt
│ newsfeatures.py
│ nnmf.py
│ stockfeatures.txt
│ stockvolume.py
│ Thumbs.db
│
└─chapter11
gp.py
gp.pyc
BoUml-6.4.4
开源UML工具,可以生成包括 C++/Java/Idl/PHP/Python 等代码,支持操作系统包括: Unix/Linux/Solaris, MacOS X 和 Windows。