
算法
AdaLeery
这个作者很懒,什么都没留下…
展开
-
算法日记 four
50.Pow(x, n)Implementpow(x,n), which calculatesxraised to the powern(xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:I...原创 2020-03-09 21:29:09 · 189 阅读 · 0 评论 -
Java 跳跃表的实现
目录跳跃表的引入容易实现的跳跃表Java实现我们知道,普通单链表查询一个元素的时间复杂度为O(n),即使该单链表是有序的,我们也不能通过2分的方式缩减时间复杂度。如上图,我们要查询元素为55的结点,必须从头结点,循环遍历到最后一个节点,不算-INF(负无穷)一共查询8次。那么用什么办法能够用更少的次数访问55呢?最直观的,当然是新开辟一条捷径去访问55。如上图,我们...转载 2020-03-08 11:06:10 · 348 阅读 · 0 评论 -
算法日记 five
leetcode6 找规律class Solution { public String convert(String s, int numRows) { if(s == null || s.length()==0 || numRows <=0) return ""; if(numRows == 1) ...原创 2020-03-09 21:27:28 · 124 阅读 · 0 评论 -
OMP正交跟踪算法和MP匹配跟踪算法
In Compressive Sensing terminology, finding y from x and A is called compression. While, on the other hand, finding original x from y and A is called reconstruction (problem). Yes, it is indeed a prob...原创 2020-01-07 21:21:00 · 224 阅读 · 0 评论 -
算法日记 third
leetcode 27Given nums = [3,2,2,3], val = 3,Your function should return length = 2, with the first two elements of nums being 2.It doesn't matter what you leave beyond the returned length.// ...原创 2019-03-30 22:31:53 · 126 阅读 · 0 评论 -
基数排序与桶排序
本文转载自:https://www.cnblogs.com/skywang12345/p/3603669.html基数排序介绍基数排序(Radix Sort)是桶排序的扩展,它的基本思想是:将整数按位数切割成不同的数字,然后按每个位数分别比较。具体做法是:将所有待比较数值统一为同样的数位长度,数位较短的数前面补零。然后,从最低位开始,依次进行一次排序。这样从最低位排序一直到最高位排序完成...转载 2019-03-13 20:52:23 · 267 阅读 · 0 评论 -
算法日记 second
Example 1:Input: "()"Output: trueExample 2:Input: "()[]{}"Output: trueExample 3:Input: "(]"Output: falseExample 4:Input: "([)]"Output: falseExample 5:Input: "{[]}"Outpu...原创 2019-03-18 09:34:53 · 628 阅读 · 0 评论 -
算法日记
选择排序:首先找到最小的那个元素将其与数组的第一个元素进行交换,再次从剩下的元素中找到最小的元素,将其与第二个元素交换,以此类推。选择排序大约需要N~2/2次比较和N次交换。public class Selections{public static void sort(int a[]){ int N=a.length; for(i=0;i<N;i++){ int m...原创 2019-03-11 10:59:44 · 210 阅读 · 0 评论 -
Python pygame study 2
#全屏显示screen=pygame.display.set_mode((640,480),0,32)screen=pygame.display.set_mode((640,480),FULLSCREEN,32)#获得机器可以支持的显示模式pygame.disp.list_modes()#将f绑定给全屏切换if event.type == KEYDOWN: if ev...原创 2018-10-26 22:29:52 · 160 阅读 · 0 评论 -
二叉堆以及堆排序算法
二叉堆:是完全二叉树,但是不是链式存储,而是顺序存储,也就是说,二叉树的所有节点都存在数组中.最大堆,左边的子节点一直大于右边的子节点最小堆,左边的子节点一直小于右边的子节点操作:1插入节点:将新的节点与其父节点比较,如果比父节点小,则上浮,即将其与父节点交换。不断将其上浮,直至其大于父节点。2删除节点:将堆的最后一个节点补到原本堆顶的位置,让其不断地下沉,即与左右子节点比较,...原创 2018-09-16 20:04:27 · 245 阅读 · 0 评论