查找
发烧的小龙虾
BUAAer
展开
-
二分查找
/*题目:二分查找作者:发烧的小龙虾时间:2018.4.17*/#include <bits/stdc++.h>using namespace std;int main(){ int a[100],i,n,x,low,high,mid,flag; map<int,int> m;//键值对,key为数字,value为对应的下标 whi...原创 2018-04-17 10:12:08 · 114 阅读 · 0 评论 -
二叉排序树的创建和删除节点
#include <stdio.h>#include <iostream>#include <string.h>#include <stdlib.h>#include <stack>using namespace std;typedef struct bnode{ int data; struct bno...原创 2018-04-17 16:30:47 · 1314 阅读 · 0 评论 -
哈希:线性探测再散列+除留余数法
#include <bits/stdc++.h>using namespace std;#define MAXSIZE 100typedef struct//哈希表的结构体类型{ int data[MAXSIZE];//一个数组 int sum;//sum存的是当前哈希表中的元素个数}HashTable;void Init(HashTable &H...原创 2018-04-18 16:24:50 · 4744 阅读 · 1 评论 -
哈希:链地址法
#include <iostream>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <math.h>using namespace std;#define MAXSIZE 20typedef struct node{ int dat...原创 2018-04-18 21:50:56 · 4805 阅读 · 1 评论 -
北邮:查找第k小的数
这个题!如果你还在用排序,那么就太浪费啦!用堆做会比较好呢!STL库里面有现成的优先队列,但是为了去重,我用了set集来判断是否重复,然后发现有个人用了一个很巧妙的方法。下面一一介绍。首先是我的方法。最大的收获就是判断set集里面有没有一个元素,不是用find,而是count!find返回的是迭代器!!而count是0和1!题目描述查找一个数组的第K小的数,注意同样大小算一样大。 如 2 1 3...原创 2018-05-05 12:52:18 · 961 阅读 · 0 评论