![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
你刷碗
牛批 嗷
展开
-
手写AVL
package com.gwf.AVLTree; public class AVLTreeDemo { public static void main(String[] args) { //int[] arr = {4,3,6,5,7,8}; //int[] arr = { 10, 12, 8, 9, 7, 6 }; int[] arr = {10, 11, 7, 6, 8, 9}; //int[] arr = {8, 10, 7原创 2020-12-19 15:30:45 · 76 阅读 · 1 评论 -
手写BST
package com.gwf.MyBST; public class myBST { public static void main(String[] args) { int[] arr = {10, 5, 15, 4, 6, 14, 16, 3, 7, 13, 17, 8, 12, 18, 9, 11, 20}; BinarySortTree bst = new BinarySortTree(); bst.root = new TreeNode(原创 2020-12-18 15:02:31 · 77 阅读 · 0 评论 -
图的最小生成树生成算法
1 图的最小生成树 1.1 Kruskal算法(C语言) ①Kruskal是基于贪心策略的求加权连通图的最小生成树的算法。 ②思路:首先按照边的权值进行从小到大排序,每次从剩余边中选择权值较小的且边的两个顶点不在同一个集合内的边(就是不会产生回路的边),加入到生成树中,知道加入了n-1条边为止。 ③时间复杂度:快速排序+m条边找n-1条 且 (M比N大很多) ==> O(MlogM+Mlog...原创 2019-11-16 14:59:19 · 840 阅读 · 0 评论 -
数据结构实现
1 并查集(Union/Find) 1.1 并查集(C语言) #include<stdio.h> int f[1001] = { 0 }, n, m, sum = 0; //这里是初始化,非常重要,数组里面存的是自己数组下标的编号 void init() { int i; for (i = 1; i <= n; i++) f[i] = i; return; } /...原创 2019-11-15 23:14:40 · 138 阅读 · 0 评论