随笔分类 - [41]Algorithm算法
-
散列函数之单散列算法
摘要:散列函数之单散列算法解决冲突问题 1. 问题 问题同《简单散列函数算法》 设有10个非负整数,用不多于20个的储存单元来存放,如何存放这10个数,使得搜索其中的某一个数时,在储存单元中查找的次数最少? 问题类似于,有10个带号码的球,放到编号为{0, 1, 2, …, 19}共20个盒子中,每个盒子 阅读全文
-
leetCode
摘要:记一次【求n以内的素数个数】的优化记录 最近在leetCode上刷提,还是满锻炼人的,为以后面试打基础吧。不多说下面开始。 问题:求[2,n]之间的素数的个数。 来源:leetCode OJ 提示: Let's start with a isPrime function. To determine 阅读全文
-
Paxos
摘要:Paxos算法原理与推导 Paxos算法在分布式领域具有非常重要的地位。但是Paxos算法有两个比较明显的缺点:1.难以理解 2.工程实现更难。 网上有很多讲解Paxos算法的文章,但是质量参差不齐。看了很多关于Paxos的资料后发现,学习Paxos最好的资料是论文《Paxos Made Simpl 阅读全文
-
深度优先算法和广度优先算法
摘要:算法:深度优先算法和广度优先算法(基于邻接矩阵) 1.写在前面 图的存储结构有两种:一种是基于二维数组的邻接矩阵表示法。 另一种是基于链表的的邻接表。 在邻接矩阵中,可以如下表示顶点和边连接关系: 说明: 将顶点对应为下标,根据横纵坐标将矩阵中的某一位置值设为1,表示两个顶点向联接。 图示表示的是无 阅读全文
-
树的插入、删除、旋转归纳
摘要:AVL 树的插入、删除、旋转归纳 参考链接: http://blog.csdn.net/gabriel1026/article/details/6311339 1126号注:先前有一个概念搞混了: 节点的深度 Depth 是指从根节点到当前节点的长度; 节点的高度 Height 是指从当前节点向下, 阅读全文
-
普利姆与克鲁斯卡尔
摘要:普利姆与克鲁斯卡尔的最小生成树(Swift面向对象版) 上篇博客我们聊了图的物理存储结构邻接矩阵和邻接链表,然后在此基础上给出了图的深度优先搜索和广度优先搜索。本篇博客就在上一篇博客的基础上进行延伸,也是关于图的。今天博客中主要介绍两种算法,都是关于最小生成树的,一种是Prim算法,另一个是Krus 阅读全文
-
图
摘要:图 图是一种比线性表和树更复杂的数据结构,在图中,结点之间的关系是任意的,任意两个数据元素之间都可能相关。图是一种多对多的数据结构。 1、基本概念 图(Graph)是由顶点的有穷非空集合和顶点之间边的集合组成,通常表示为:G(V,E),其中,G表示一个图,V是图G中顶点的集合,E是图G中边的集合。 阅读全文
-
优先队列
摘要:数据结构与算法(五),优先队列 这节总结一下优先队列的常用实现方法。 1、基本概念 普通的队列是一种先进先出的数据结构,元素在队列尾追加,而从队列头删除。在优先队列中,元素被赋予优先级。当访问元素时,具有最高优先级的元素最先删除。优先队列具有最高级先出 (largest-in,first-out)的 阅读全文
-
数据结构与算法1
摘要:数据结构与算法(一),概述 转载请注明出处:http://www.cnblogs.com/wangyingli/p/5919297.html 数据结构学了有一年的时间了,但是一直没有好好的总结一下,现在回想起来,感觉好像都不怎么记得了。所以接下来一段时间我将重新学习一下,算是温故而知新了。本着「分享 阅读全文
-
滴滴出行秋招编程题
摘要:算法是什么我记不住,But i do it my way. 解一道滴滴出行秋招编程题。 只因在今日头条刷到一篇文章,我就这样伤害我自己,手贱。 刷头条看到一篇文章写的滴滴出行2017秋招编程题,后来发现原文在这里http://www.cnblogs.com/SHERO-Vae/p/5882357.h 阅读全文
-
九章算法
摘要:九章算法 前言 第一天的算法都还没有缓过来,直接就进入了第二天的算法学习。前一天一直在整理Binary Search的笔记,也没有提前预习一下,好在Binary Tree算是自己最熟的地方了吧(LeetCode上面Binary Tree的题刷了4遍,目前95%以上能够Bug Free)所以还能跟得上 阅读全文
-
二分查找
摘要:二分查找 1 二分查找 二分查找是一个基础的算法,也是面试中常考的一个知识点。二分查找就是将查找的键和子数组的中间键作比较,如果被查找的键小于中间键,就在左子数组继续查找;如果大于中间键,就在右子数组中查找,否则中间键就是要找的元素。 (图片来自《算法-第4版》) 每次移动left和right指针的 阅读全文
-
数据结构与算法javascript描述
摘要:《数据结构与算法javascript描述》--数组篇 导读: 这篇文章比较长,介绍了数组常见的操作方法以及一些注意事项,最后还有几道经典的练习题(面试题)。 数组的定义: JavaScript 中的数组是一种特殊的对象,用来表示偏移量的索引是该对象的属性,索引可能是整数。然而,这些数字索引在内部被转 阅读全文
-
谈论算法
摘要:不能只用O记号来谈论算法? 在刷LeetCode-1TwoSum的时候,有个人在论坛留言,大致意思如下: 我的算法击败了90%的人,O(nlgn)算法比O(n)算法快。 我觉得这个人是不懂算法的。让我一步一步解释。 # O的含义 通俗的说,O表示忽略系数的复杂度上限,常常用一个量级表示,比如n,nl 阅读全文
-
理解数字图像处理中的卷积
摘要:理解数字图像处理中的卷积 彻底理解数字图像处理中的卷积-以Sobel算子为例 作者:FreeBlues 修订记录 2016.08.04 初稿完成 2016.08.04 初稿完成 概述 卷积在信号处理领域有极其广泛的应用, 也有严格的物理和数学定义. 本文只讨论卷积在数字图像处理中的应用. 在数字图像 阅读全文
-
Reverse String
摘要:Leetcode 344. Reverse String 题目网址:https://leetcode.com/problems/reverse-string/ Write a function that takes a string as input and returns the string r 阅读全文
-
K - 近邻算法
摘要:机器学习算法( 二、K - 近邻算法) 一、概述 k-近邻算法采用测量不同特征值之间的距离方法进行分类。 工作原理:首先有一个样本数据集合(训练样本集),并且样本数据集合中每条数据都存在标签(分类),即我们知道样本数据中每一条数据与所属分类的对应关系,输入没有标签的数据之后,将新数据的每个特征与样本 阅读全文
-
二叉 查找树 排序树 搜索树
摘要:二叉查找树 _ 二叉排序树 _ 二叉搜索树_C++ 一、数据结构背景+代码变量介绍 二叉查找树,又名二叉排序树,亦名二叉搜索树 它满足以下定义: 1、任意节点的子树又是一颗二叉查找树,且左子树的每个节点均小于该节点,右子树的每个节点均大于该节点。 2、由1可推出,任意节点的左孩子小于该节点,右孩子大 阅读全文
-
Prisma
摘要:AI修图艺术:Prisma背后的奇妙算法 | 深度 投递人 itwriter 发布于 2016-07-30 12:47 评论(2) 有712人阅读 原文链接 [收藏] « » 雷锋网按:本文作者系图普科技工程师。 在 Prisma 的应用下载评论区看到这么一句好玩的话:世界一半人在用《Pokemon 阅读全文
-
重构二叉树
摘要:重构二叉树 这是剑指offer中关于二叉树重构的一道题。题目原型为: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并 阅读全文