数据结构
djinglan
喜欢
展开
-
求第K个最大的数
#include #define N 100 #define K 2 int main(void) { int A[N]={1,2,3,4,5,6}; int B[N]; int count=0, i,maxval,col=0; for (i=0; i B[i] = A[i]; while (count { maxval = B[0]; for原创 2012-04-03 15:19:34 · 826 阅读 · 0 评论 -
动态开辟的链表 可以当做数组使用
#include #include #include int main(void) { int *p=NULL; int a = 2; p = (int *)malloc(sizeof(int)*5); memcpy(&p[2], &a, sizeof(int)); printf("%d %#x\n", p[2], &p[2]); return 0; }原创 2012-05-19 16:51:59 · 790 阅读 · 0 评论 -
栈的链接实现
#include #include typedef int DataType; struct node { DataType info; node * next; }; int main(void) { struct node *top, *tep; int d; top = (struct node *)malloc(sizeof(stru原创 2012-06-17 14:10:06 · 667 阅读 · 0 评论 -
循环队列简单实现
#include #include #define MAX 5 typedef struct { int key; }element; int main() { element list[MAX]; int rear = 0; int front = 0; int d, err; element tm原创 2012-06-18 22:04:47 · 664 阅读 · 0 评论 -
程序员的数学--笔记
第一章 在10进制计数法中,位数少,但是数字种类多;对人类来说,比较易用。 在2进制计数法中,数字种类少,位数多;对计算机来说,比较易用。 N进制计数法:使用0,1,2,3,...,N-1,共N种;从右往左分别为N0的位,N1的位,N2的位...(基数是N)。 以上,使用按位计数。 罗马计数法:不使用按位计数。数位没有意义;只表示数字本身;没有0.原创 2013-02-21 10:01:32 · 990 阅读 · 0 评论 -
经典字符串hash函数介绍及性能比较
各种字符串Hash函数 http://www.cnblogs.com/atlantis13579/archive/2010/02/06/1664792.html http://blog.csdn.net/icefireelf/article/details/5796529 字符串Hash函数对比 分类: 数据结构与算法 2010-08-08 11:21 783人阅读 评论(0)收藏转载 2013-04-17 11:08:11 · 30136 阅读 · 0 评论 -
hash函数的设计思想与方法
hash函数的设计思想及方法 hash函数依赖于键的类型。对于每一种可能使用的键 我们需要不同的hash函数。为了高效,同常避免 使用显示类型转换,尽力代之以将键视为机器字的 二进制正数表示的思想,这样有利于对其使用算术 运算。一个优秀的hash函数应该考虑到键的所有位, 尤其对于由字符组成的键。要计算出长键的取模 哈希函数,可以将键分块转换。或者用两个或三个 不同的has原创 2013-04-17 16:00:18 · 3782 阅读 · 0 评论 -
堆排序--算法导论
#include "stdafx.h" #include #include #include #include #include #include using namespace std; #define SIZE 10 //维持堆的性质(假设i的左右两支已经符合大堆的性质) void MaxHeapify(int data[], int index, in原创 2013-12-25 15:34:31 · 1286 阅读 · 0 评论 -
中缀表达式转后缀表达式求值
笔试出这道题出了好几次了, 总是写不好,还是得好好准备啊。参考百度百科,但是那里不是写的太好,改进了一些, 并没有改完。等有时间再改改。 // Test0.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #原创 2013-12-26 23:03:25 · 1853 阅读 · 0 评论