
数据结构
算了咯,还能咋样
这个作者很懒,什么都没留下…
展开
-
插入排序和希尔排序
插入排序:从数组第二个元素开始,如果他比前一个元素小,那么用一个帮助空间将他存储起来,然后将他之前比他大的元素通通后移,将他插入最后一个后移的元素之前,对于一个基本有序的数列来说很快捷,时间复杂度为O(n^2); #include <stdio.h> #include <stdlib.h> #include <time.h> #define MA...原创 2018-08-14 15:23:50 · 168 阅读 · 0 评论 -
堆排序和归并排序
各种排序放大的时间复杂度,空间复杂度,以及稳定性 三中排序的移动次数比较 堆排序的时间复杂度为O(nlogn),无论好还他的时间复杂度是一样的 #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAXSIZE 10 typedef struct { int r[M...原创 2018-08-15 16:15:30 · 1492 阅读 · 0 评论 -
C语言链栈实现的简易计算器
#include <stdio.h> #include <stdlib.h> #define OK 1 #define ERROR 0 typedef struct Stack_num { int num; struct Stack_num *next; }Stack_num,*LinkStack_num_ptr; typedef struct LinkStack_n...原创 2018-08-08 16:59:55 · 1666 阅读 · 3 评论 -
快速排序以及快速排序的优化
快速排序 #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAXSIZE 10 typedef struct { int r[MAXSIZE]; int length; }SqList; int Partition(SqList *L,int low,int high); ...原创 2018-08-13 22:31:22 · 382 阅读 · 0 评论 -
反转链表
输入值为正序链表,返回值为逆序后的头结点 ListNode* ReverseList(ListNode* pHead) { if(pHead!=NULL) { ListNode *rHead=pHead; ListNode *p=pHead->next; pHead->next=NULL; ListNode *q; while(p!=NULL) ...原创 2018-08-18 14:29:21 · 202 阅读 · 0 评论 -
在vector容器二维数组中查找元素
#include <iostream> #include <vector> using namespace std; bool Find(int target, vector<vector<int> > array) { for(vector<vector<int> >::iterator it1=array.begin...原创 2018-08-18 14:31:58 · 4138 阅读 · 0 评论 -
笔试题——用容器栈实现队列的 出入队列
#include <iostream> #include <stack> using namespace std; stack<int> stack1; stack<int> stack2; void Init() { for(int i=0;i<5;i++) { stack1.push(i+1); } } void push(in...原创 2018-08-18 15:10:01 · 208 阅读 · 0 评论 -
字符串中单词的反转
基本思想是 将整个字符串反转,再将字符串中的每个单词反转 #include <iostream> using namespace std; int reverseStr(char *str,int begin,int end) { char tmp; if(str==NULL) { return 0; } if(begin<end) { tmp=str[b...原创 2018-08-22 14:17:11 · 815 阅读 · 0 评论