- 博客(12)
- 收藏
- 关注
转载 哈希冲突的四种解决方法!!
解决哈希冲突的四种方法1.开放地址方法 (1)线性探测 按顺序决定值时,如果某数据的值已经存在,则在原来值的基础上往后加一个单位,直至不发生哈希冲突。 (2)再平方探测 按顺序决定值时,如果某数据的值已经存在,则在原来值的基础上先加1的平方个单位,若仍然存在则减1的平方个单位。随之是2的平方,3的平方等等。直至不发生哈希冲突。 (3)伪随机探测 按顺序决定值时,如果某数据已经存在,通过随机函数随机生成一个数,在原来值的基础上加上随机数,直至不发生哈希冲突。
2020-08-06 14:23:12 2219
原创 2020-08-06 Set、List、Map简单总结
三者关系图Setset接口是是无序的,set中不包含重复的元素,也就是说set中不存在两个这样的元素a1.equals(a2)结果为true。同时支持对象的添加和删除。HashSet:它存储唯一元素并允许空值,它由HashMap支持,它不保持插入顺序,它不是线程安全的,创建HashSet的实例时,会初始化此内部HashMap,HashSet的性能主要受两个参数影响 - 初始容量和负载因子。TreeSet:在集中以升序对对象排序的集的实现,这意味着从一个TreeSet对象获得第一个迭代器.
2020-08-06 13:50:52 176
转载 最短路径丶万
#include <stdio.h>#include<cstring>#include<iostream>using namespace std;struct Gh{ int n;//顶点数 int m;//边数 int weight; int e[10][10];};int main(){ Gh G; char ch[10]...
2018-07-16 15:55:24 134
转载 七巧板着色问题
#include <iostream>using namespace std;static int total;const int n=7;const int data[n][n]={{0,1,0,0,1,0,1}, {1,0,0,1,0,1,0}, {0,0,0,0,1,0,1}, ...
2018-07-09 19:36:04 2985 1
转载 邻接矩阵深度优先广度优先遍历
#include <iostream>#include<queue>#include<string>using namespace std;int visited[100];typedef struct{ string ch;}phen[100];typedef struct{ int arc[30][30]; int arcnum; i...
2018-07-09 19:33:30 929
转载 8枚硬币问题
#include<iostream>using namespace std;void eightcoin(int arr[]);void compare(int a, int b,int real, int index1,int index2);void print(int jia, int zhen, int i);int main(){ int i = 0; int a...
2018-07-09 19:29:31 732
翻译 最小生成树
#include <iostream>#include<stdio.h>using namespace std;#define MAXSIZE 30#define MAXCOST 32767typedef struct{ int arc[30][30]; int u;//边的起始点 int v;//边的终点 int w;//边的权值 int v...
2018-07-09 19:26:59 129
原创 c++最短路径,
#include <iostream>#include <cstring>#include <iomanip>using namespace std;template <class T>class MGraph{public: int arc[30][30]; int vexnum; int arcnum; T *vertex...
2018-07-09 19:25:40 132
转载 KMP算法
#include<iostream>#include<stdlib.h>using namespace std;void NEXT(const string &T, char *next){ next[0] = -1; for (int i = 1; i<T.size(); i++) { int j = next[i - 1];...
2018-07-09 19:23:13 88
转载 简单二叉树
#include <iostream>#include<cstdio>#include<cstdlib>#include<queue>using namespace std;typedef struct BinaryTreeNode{ char data; struct BinaryTreeNode *Left; struct Bi...
2018-07-09 19:22:11 119
转载 二叉排序树
#include <stdio.h>#include<iostream>#include <stdlib.h>#include <stdbool.h>using namespace std;#define N 7 //插入查找树数组长度/* 二叉查找树 操作*/typedef int Elemtype;typedef struct BSTNode...
2018-07-09 19:18:03 116
转载 除留取余法
#include <iostream>#include <ctime>using namespace std;#define SUCCESS 1#define UNSUCCESS 0#define HASHSIZE 12#define NULLKEY 0xffffffff/2typedef struct{ int *elem; int count;}HashTable;t...
2018-07-09 19:17:01 2181 2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人