
算法
cupidove
这个作者很懒,什么都没留下…
展开
-
位操作
/* base.h:基本操作的位运算实现 */#ifndef BASE_H#define BASE_H#define word int#define uword unsigned int/* 将最右侧的1位改成0位 */#define right1to0(x) ((x)&((x)-1))/* 向右传播最右侧的1位 */#define right1torig(x) ((x)转载 2013-07-22 13:17:39 · 933 阅读 · 0 评论 -
scatter plots smooth算法 lowess
/* * c++ implementation of Lowess weighted regression by * Peter Glaus http://www.cs.man.ac.uk/~glausp/ * * * Based on fortran code by Cleveland downloaded from: * http://netlib.org/go/lowe转载 2016-08-20 11:49:21 · 3004 阅读 · 0 评论 -
802.11n 速率计算方法
802.11n采用了MIMO多天线技术,当存在两根天线(即假如是2X2时),在每种带宽下它存在16种速率(记为MCS0-MCS15,MCS:Modulation and coding scheme)(当有3根或者4根天线都同时能够发射数据的时候,理论上应该是1根天线时的3倍或4倍)。这16种速率分别是:HT20时:(MCS0-MCS7) 6.5M、13M、19.5M、26M、39M、52M、5转载 2013-10-01 12:24:28 · 2818 阅读 · 0 评论 -
boom filter
boomfilter.h#ifndef __BLOOM_H__#define __BLOOM_H__#include typedef unsigned int (*hashfunc_t)(const char *);typedef struct { size_t asize; unsigned char *a; size_t nfuncs; hash转载 2013-07-22 11:01:44 · 1044 阅读 · 0 评论 -
二分查找算法
int search(int array[], int n, int v){ int left, right, middle; left = 0, right = n - 1; while (left <= right) { middle = (left + right) / 2; if (array[middle] > v)原创 2013-07-19 14:17:42 · 603 阅读 · 0 评论 -
bit-map海量数据处理
海量数据排序问题:文件包含1千万条电话号码记录(10**7次方),每条记录都是7位整数,没有重复的整数。要求对文件进行排序,注意大约只有1MB的内存空间可用,有充足的磁盘存储空间可用。请设计一个高效的算法。 (1)运用多趟算法:如果每个号码都使用32位整数来表示,则在1MB存储空间里大约可以存250000个号码。因此,可以使用遍历输入文件40趟的程序来完成排序。在第一趟中,将0至249999转载 2013-07-22 10:54:57 · 770 阅读 · 0 评论 -
高效产生不重复的随机数
//purpose: 生成随机的不重复的测试数据 //1000w数据量,要保证生成不重复的数据量,一般的程序没有做到。但,本程序做到了。 #include #include #include #include #include #include #define size 10000000 int num[size] = {0}; void swap(i原创 2013-07-22 16:37:37 · 1142 阅读 · 0 评论 -
快速选择SELECT算法的实现
本节,咱们将依据下图所示的步骤,采取中位数的中位数选取枢纽元的方法来实现此SELECT算法, 不过,在实现之前,有个细节我还是必须要提醒你,即上文中2.2节开头处所述,“数组元素索引是从“0...i”开始计数的,所以第k小的元素应该是返回a[i]=a[k-1].即k-1=i。换句话就是说,第k小元素,实际上应该在数组中对应下标为k-1”这句话,我想,你应该明白了:返回数组中第k小的元素,转载 2013-07-23 11:27:14 · 6065 阅读 · 0 评论 -
如何给10^7个数据量的磁盘文件排序
//purpose: 生成随机的不重复的测试数据 //1000w数据量,要保证生成不重复的数据量,一般的程序没有做到。但,本程序做到了。 #include #include #include #include #include #include #include #include #include #define BITSPERWORD 32#defin原创 2013-07-23 10:17:55 · 803 阅读 · 0 评论 -
fls - find last (most-significant) bit set
static int fls(int x) { int r = 32; if (!x) return 0; if (!(x & 0xffff0000u)) { x <<= 16; r -= 16; } if (!(x & 0xff000000u)) {原创 2013-07-19 14:15:11 · 1056 阅读 · 0 评论 -
排序
1、直接插入排序:把后面未排序部分的首个数插入到前面已排序部分的正确位置上去,直到全部排好顺序。直接插入排序是稳定的,算法时间复杂度O(n^2)。[cpp] view plaincopy/* 直接插入排序 */ void insert_sort(int v[],int n){ register int i,j,temp; for(i=1; i/*转载 2013-07-22 10:50:22 · 604 阅读 · 0 评论 -
查找有序序列中 重复/不存在 的数算法
/* * 查找有序序列中 重复/不存在 的数算法演示 * 版权所有:http://www.cppblog.com/converse/ */#include #include #include #define FUNC_IN() printf("\nin %s\n\n", __FUNCTION__)#define FUNC_OUT() printf("\nout %s\n转载 2013-07-19 14:25:33 · 1206 阅读 · 0 评论 -
数据结构之队列
queue.h #ifndef __QUEUE_H__ #define __QUEUE_H__ typedef struct Queue_node { void *data; struct Queue_node* next; }Queue_node; typedef struct Queue {转载 2013-07-19 17:37:15 · 670 阅读 · 0 评论 -
通信经典书籍介绍
1.《An Introduction to Signal Detection and Estimation》——H. Vincent Poor这本书是普林斯顿大学统计信号处理专业课的教材,可以得见,此书是以理论见长。我觉得工程应用涉及得不多。理论算法倒是讲得很透彻。书中的推导论述确实很严谨,无可挑剔,本人觉得适合研究生阅读,虽然是导论,但是我们的一般本科生的理论水平比起普林斯顿大学的本科生转载 2017-05-04 16:00:02 · 16034 阅读 · 2 评论