Skip to content

Instantly share code, notes, and snippets.

@tinylamb
tinylamb / tree.c
Last active August 29, 2015 13:57
ADT tree.keywords:left child right sibling
/*
* =========================================================
* Filename: ADT_tree.c
* Description: 数据结构之树
*
* =========================================================
*/
#include <stdio.h>
#include <stdlib.h>
@tinylamb
tinylamb / 倒排索引的交并差运算
Created March 12, 2014 06:48
信息检索之布尔查询
问题:有文档集合D,给定词汇t1,t2,我想知道同时包含t1 t2的文档有哪些?
问题转化为,倒排索引表上的交,并,差 运算。结合Weien图
倒排索引的由来:
所谓倒排就是某个词在哪些文档中出现,正好与一个文档中包含哪些词相反。
词汇-文档矩阵包含上述两个概念。
倒排表的交运算
L1={ai},L2={bi} ;L1 L2均有序,现求L1 ∩ L2
@tinylamb
tinylamb / rails.c
Last active August 29, 2015 13:56
判断一个出栈序列能不能从1,2,3,..,n 经过栈处理后生成
/*
* =========================================================
* Filename: rails.c
* Description: 判断一个出栈序列能不能从1,2,3,..,n 经过栈处理后生成。
*
* =========================================================
*/
#include <stdio.h>
#define MAX 1010
int main(){
@tinylamb
tinylamb / queue.c
Last active August 29, 2015 13:56
ADT Queue.循环队列
/*
* =========================================================
* Filename: throwcards.c
* Description: google Throwing cards away I
* 题目大意:给n张牌,放成一叠,从上到下编号从1到n,当至少还有两张牌时
* 丢弃最上面的牌,然后把新的最上面的牌放到最下面,一直重复,直到只剩下一张牌
* 输出丢弃牌的序列。
* =========================================================
*/
#include <stdio.h>
@tinylamb
tinylamb / textfilter.py
Last active January 1, 2016 20:38
naive bayes,textfilter
#coding=utf-8
import re
import os
import nltk
import math
from nltk.corpus import stopwords
stopword=stopwords.words('english')
traindir='./train'
testdir='./test'
@tinylamb
tinylamb / document filter
Created December 20, 2013 09:10
document filter.《programming collective intelligence》
/*
项目目标:
实现文本分类:分类体系为财经、科技、汽车、房产、体育、娱乐、其它类
,利用网站的新闻主页,训练一个分类器。能够实现新的网页的分类。
*/
@tinylamb
tinylamb / random_walk.c
Created December 15, 2013 13:20
模拟随机游走
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define START 1
#define END 10
#define TEST 10
#define TIMES 100000
int main(){
srand(time(NULL));
float sum;
@tinylamb
tinylamb / unget.c
Created December 11, 2013 17:00
小程序:一列数[1 2 2 6 10 11 10 15 15...],相邻两数之间的距离小于2时,将其做平均,且输出。 输入:[1 2 2 6 10 11 10 15 15...] 输出:[5/3 ,6 , 31/3 , 15]
#include <stdio.h>
#include <stdlib.h>
#define STACKSIZE 10 /* 用栈存储不满足条件数,下一次输入从栈开始 */
#define QUEUESIZE 100 /* 用队列存储输入 */
#define N 100 /* 存储输出结果的数组大小 */
#define Emptystack(s) s.top==0
#define Emptyqueue(q) q.count==0
#define GAP 2
/*---------------------------------------------------
* 栈操作:声明栈sta 及相应的压栈 出栈操作
@tinylamb
tinylamb / maze.c
Last active December 30, 2015 02:29
backtracking to find a path in maze
/*
* =========================================================
* Filename: maze.c
* Description: backtracking to find a path in maze
* refer: http://blog.csdn.net/synapse7/article/details/14411365
* =========================================================
*/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
@tinylamb
tinylamb / calculator.c
Last active December 29, 2015 10:39
基于中缀表达式的计算器.keywords: inorder tree变后缀; enum 类型与宏定义
/*
* =========================================================
* Filename: calculator.c
* Description: deal with expression like this (4+2)*5-6/(2+1)
* number , + - * / , ()
* 1.convert in-order to post-order
* 2.you know how to compute post-order expr
*
* =========================================================
*/