数据结构和算法
Hello_Roson
这个作者很懒,什么都没留下…
展开
-
Linux下单链表的实现
#define OK 0 //no error#define ERROR 1 //some errortypedef int ElemType;typedef struct node{ElemType data;struct node *next;}linklist,node;typedef enum bool{ok = 0,error = 1}bool;void CreatList(linkli原创 2014-06-08 16:43:11 · 764 阅读 · 0 评论 -
第一个只出现一次的字符
题目: char FirstNotRepeatingChar(char* pString); bool InvalidInput = false; char FirstNotRepeatingChar(char* pString) { if (pString == NULL) { InvalidInput = true; return 0; } unsigned int原创 2014-07-09 22:10:50 · 425 阅读 · 0 评论 -
最小的k个数
题目:输入n个数,找出其中最小的K个数。例如输入4原创 2014-07-08 22:11:21 · 410 阅读 · 0 评论 -
丑数
题目:我们把只包含因子2、3、和5的数称作丑数原创 2014-07-09 21:14:53 · 396 阅读 · 0 评论 -
朴素的和KMP模式匹配算法
朴素的模式匹配算法:原创 2014-06-21 17:41:15 · 571 阅读 · 0 评论 -
从上往下打印二叉树
从上往下打印二叉树的每个结点,同一层的结点按照从左到右的顺序打印。原创 2014-07-29 21:17:14 · 353 阅读 · 0 评论 -
二叉搜索树的后序遍历序列
输入一个整数数组,判断该数组是不是原创 2014-07-29 21:07:08 · 395 阅读 · 0 评论 -
哈希表
链地址法实现哈希表(散列表)的代码:原创 2014-06-21 17:59:55 · 510 阅读 · 0 评论 -
栈和队列
#include #include #define MAXSIZE 10 #define ERROR 0 #define OK 1 typedef int SElemType; typedef struct { SElemType data[MAXSIZE]; int top; }pStack; void InitStack(pStack *p) { int i = 0; p->t原创 2014-06-21 17:35:21 · 440 阅读 · 0 评论 -
栈的压入、弹出序列
bool isPopOrder(const int *pPush,const int *pPop,int nLength) { bool isPossible=false; if (pPush == NULL || pPop == NULL || nLength <= 0) { stack dataStack; const int *pNextPush = pPush; cons原创 2014-07-29 20:54:00 · 356 阅读 · 0 评论 -
包含min函数的栈
#include #include using namespace std; template class StackWithMin { public: StackWithMin(void){} virtual ~StackWithMin(void){} T& top(void); const T& top(void)const; void push(const T& value)原创 2014-07-29 20:45:55 · 555 阅读 · 0 评论 -
排序算法
本文内容主要是各个排序算法的代码,主要有原创 2014-07-08 16:00:56 · 425 阅读 · 0 评论 -
连续子数组的最大和
题目:输入一个整型数组,数组里有正数也有负数。shuzu原创 2014-07-09 12:44:36 · 431 阅读 · 0 评论