算法
JackLi_csdn
这个作者很懒,什么都没留下…
展开
-
队列
高性能队列Disruptor、Linux环形缓存用到了循环并发队列 Java concurrent并发包利用ArrayBlockingQueu实现公平锁 循环队列:队空head==tail,队满(tail+1)%n=head,取余是为了将tail的值降到[0,n-1]的区间,而且为了从头取出数据时,也必须head=(head+1)%n;同时,循环队列为了进行队满和队空的区分,浪费了一个存储空间 阻...原创 2019-12-22 21:33:39 · 135 阅读 · 0 评论 -
栈
栈: 顺序栈,用数组实现的栈,支持动态扩容的顺序栈,平时开发中并不常见; 链式栈,用链表实现的栈, 应用场景: (1)浏览器的前进后退功能,两个栈 (2)函数调用栈:OS给每个线程分配了一块独立的内存空间,这块内存被组织成“栈”,用来存储函数调用时的临时变量,每进入一个函数,就会将临时变量作为一个栈帧入栈,当被调用的函数执行完成并将值返回后,就将这个函数对应的栈帧出栈; (3)编译器利用栈实现表达...原创 2019-09-02 22:33:40 · 118 阅读 · 0 评论 -
递归、迭代、循环
https://www.cnblogs.com/zhizhan/p/4892886.html https://blog.csdn.net/qsbbl/article/details/76733215原创 2018-10-24 14:45:35 · 245 阅读 · 0 评论 -
数组
数组支持随机访问,根据下标随机访问的时间复杂度是O(1),但是“数组的查找时间复杂度是O(1)”,这种说法是不正确的,即使是对于排序好的数组,用二分查找,时间复杂度也是O(logn) ...原创 2019-08-24 20:23:07 · 108 阅读 · 0 评论 -
算法复杂度
时间复杂度 可以把所有对数阶的时间复杂度都记为 O(logn)。O(log3n) = O(C * log2n),其中 C=log32 是一个常量。在采用大 O 标记复杂度的时候,可以忽略系数,即 O(Cf(n)) = O(f(n))。如果一段代码的时间复杂度是 O(logn),我们循环执行 n遍,时间复杂度就是 O(nlogn) 了 空间复杂度 常见的空间复杂度就是 O(1)、O(n)、O(n2 ...原创 2019-08-24 20:19:42 · 330 阅读 · 0 评论 -
topk 堆
https://blog.csdn.net/juzihongle1/article/details/70212243 堆(Heap)、堆排序和TopK https://www.cnblogs.com/eudiwffe/p/6202111.html 《排序算法》——堆排序(大顶堆,小顶堆,Java) https://blog.csdn.net/Gamer_gyt/article/details/47...转载 2018-11-28 15:21:04 · 409 阅读 · 0 评论 -
动态规划
1、0-1背包问题 https://www.cnblogs.com/lfeng1205/p/5981198.html转载 2019-01-13 00:56:22 · 138 阅读 · 0 评论 -
dfs bfs
200.Number of Islands Given a 2d grid map of '1’s (land) and '0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vert...原创 2019-01-17 13:27:52 · 151 阅读 · 0 评论 -
图
https://www.cnblogs.com/hapjin/p/4760934.html 【数据结构】图(邻接矩阵、邻接表)的JAVA代码实现 https://blog.csdn.net/qq_38410730/article/details/79587747 java图的邻接表实现两种方式及实例应用分析 https://blog.csdn.net/feilong_csdn/article/de...转载 2019-01-06 01:46:15 · 123 阅读 · 0 评论 -
二叉树
1、二叉搜索树最近公共祖先 public static TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if (root==null) { return root; } while(root!=null){ if ((p.val<=root.val&&amp...原创 2019-01-04 16:27:36 · 144 阅读 · 0 评论 -
链表
1、删除节点 public static void deleteNode(ListNode node,int a) { ListNode p=node; ListNode q=node; while (p.next!=null) { if (p.val!=a) { p=p.next; q.next=p; } q.ne...原创 2019-01-04 16:23:25 · 154 阅读 · 0 评论 -
回文
public static boolean isPalindrome(String s){ int i=0;int j=s.length()-1; boolean flag=true; while(i<j) { while (!(isLetterOrDigi(s.charAt(i)))&&i<j) { i++; } while (!...原创 2019-01-04 16:21:38 · 154 阅读 · 0 评论 -
字符串
public String reverseString2(String s) { char[] word = s.toCharArray(); int i = 0; int j = s.length() - 1; while (i &amp;lt; j) { char temp = word[i]; wor...转载 2019-01-04 16:20:39 · 151 阅读 · 0 评论 -
flann
http://blog.csdn.net/jasonding1354/article/details/44038539转载 2017-09-07 15:31:09 · 513 阅读 · 0 评论 -
欧氏距离计算
一、不转换成rddval pointsWithIndex=list.asScala.toList.zipWithIndex val dis = pointsWithIndex.flatMap(a => pointsWithIndex.filter(_._2 > a._2).map((a, _))) .map({ case (a, b) => (a._1.getTrackletID, b.原创 2017-08-23 16:59:10 · 3961 阅读 · 0 评论 -
相似度计算方式的总结:java或python实现代码
http://blog.csdn.net/zy825316/article/details/19129531转载 2017-08-01 17:10:17 · 530 阅读 · 0 评论