数据结构算法
文章平均质量分 65
xiaoqi030611a
这个作者很懒,什么都没留下…
展开
-
最大子段和
问题表述 n个数(可能是负数)组成的序列a1,a2,…an.求该序列 例如: 序列(-2,11,-4,13,-5,-2) ,最大子段和: 11 - 4 + 13=20。 (1)穷举算法: O(n3), O(n2) (2)分治法: 将序列a[1:n]从n/2处截成两段:a[1:n/2], a[n/2+1:n] 实例三、最大子段和 问题表述 n个数(可能是负数)组成原创 2012-10-09 13:49:58 · 479 阅读 · 0 评论 -
链表逆序
#include using namespace std; typedef struct LinkNode { int data; LinkNode *next; } *Node; Node linkReverse(Node head) { Node ptr = NULL; Node previous = NULL; while (head->next) { ptr = he原创 2012-09-17 10:06:16 · 260 阅读 · 0 评论 -
插入排序 和 快速排序
#include using namespace std; void print_array(int array[], int len) { for (int i = 0; i < len; i++) { cout << array[i] << " "; } cout << endl; } //插入排序 void InsertSort(int array[], i原创 2012-09-20 22:55:43 · 258 阅读 · 0 评论 -
快速排序的非递归实现
#include #include using namespace std; void print_array(int array[], int len) { for (int i = 0; i { cout } cout } int Partition(int array[], int low, int high) { int t原创 2012-09-23 23:19:38 · 242 阅读 · 0 评论 -
hash函数实现
Hash Functions A comprehensive collection of hash functions, a hash visualiser and some test results [see Mckenzie et al. Selecting a Hashing Algorithm, SP&E 20(2):209-224, Feb 1990] will be avai转载 2012-10-21 11:37:32 · 348 阅读 · 0 评论 -
hash 实现源码
Hashtebl.h #ifndef _HASHTABLE_H #define _HASHTABLE_H /*********************************************************** * 数据类型定义原创 2012-10-22 22:07:33 · 302 阅读 · 0 评论