随笔分类 - [41]Algorithm算法
-
N位N进制里有多少个N
摘要:32位二进制里有多少个1 https://blog.csdn.net/zhangsj1007/article/details/81411063 有这样一道计算机问题“32位二进制里面有多少个1”。这是一道比较普遍也比较简单的计算机题目,但是之前看过一篇文章,不单单是答案,而是在各个方面对该问题做了考 阅读全文
-
理解分布式id生成算法SnowFlake
摘要:理解分布式id生成算法SnowFlake https://segmentfault.com/a/1190000011282426 articleHeader2 分布式id生成算法的有很多种,Twitter的SnowFlake就是其中经典的一种。 概述 SnowFlake算法生成id的结果是一个64b 阅读全文
-
代码
摘要:手撕代码,你怕不怕? 前言:不管是远程的视频面试,还是现场的面试,都有可能会有手撕代码的环节,这也是很多童鞋包括我(虽然还没遇到过..)都很头疼的东西,可能是因为 IDE 自动提示功能用惯了或是其他一些原因,总之让我手写代码就是感觉很奇怪..但是我想的话,这应该侧重考察的是一些细节或者是习惯方面的一 阅读全文
-
快速排序
摘要:快速排序 https://www.cnblogs.com/wipan/p/9461005.html 对于快速排序,相信大家都有听过,这是一个被封为圣经的算法,足以体现算法的神奇的伟大。接下来本人将从算法思想、算法具体实现、不同情况下的复杂度、算法的优化和代码展示等几个方面为读者深入讲解。 一、算法思 阅读全文
-
限流组件
摘要:net的分布式系统限流组件 https://www.cnblogs.com/vveiliang/p/9049393.html 在互联网应用中,流量洪峰是常有的事情。在应对流量洪峰时,通用的处理模式一般有排队、限流,这样可以非常直接有效的保护系统,防止系统被打爆。另外,通过限流技术手段,可以让整个系统 阅读全文
-
剑指offer
摘要:《剑指offer》 1.二维数组中的查找 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 public class Solution { public boolean Find(i 阅读全文
-
算法题
摘要:算法题 前言 清明不小心就拖了两天没更了~~ 这是十道算法题的第二篇了~上一篇回顾:十道简单算法题 最近在回顾以前使用C写过的数据结构和算法的东西,发现自己的算法和数据结构是真的薄弱,现在用Java改写一下,重温一下。 只能说慢慢积累吧~下面的题目难度都是简单的,算法的大佬可直接忽略这篇文章了~入门 阅读全文
-
B树和B+树
摘要:B树和B+树 简介:本文主要介绍了B树和B+树的插入、删除操作。写这篇博客的目的是发现没有相关博客以举例的方式详细介绍B+树的相关操作,由于自身对某些细节也感到很迷惑,通过查阅相关资料,对B+树的操作有所顿悟,写下这篇博客以做记录。由于是自身对B+树的理解,肯定有考虑不周的情况,或者理解错误的地方, 阅读全文
-
KMP算法
摘要:什么是KMP算法?KMP算法推导 花了大概3天时间,了解,理解,推理KMP算法,这里做一次总结!希望能给看到的人带来帮助!! 如果你觉得有帮助,欢迎分享给其他人!送人玫瑰手有余香! 欢迎留言,哪怕一个字,大家的鼓励就是我写作的动力! 如果你觉得写的很烂,请告诉我哪里写的不好,我尽量调整! 1.什么是 阅读全文
-
排序算法
摘要:十大经典排序算法最强总结(含JAVA代码实现) 最近几天在研究排序算法,看了很多博客,发现网上有的文章中对排序算法解释的并不是很透彻,而且有很多代码都是错误的,例如有的文章中在“桶排序”算法中对每个桶进行排序直接使用了Collection.sort()函数,这样虽然能达到效果,但对于算法研究来讲是不 阅读全文
-
C# 蚁群优化算法实现
摘要:C# 蚁群优化算法实现 需求为(自己编的,非实际项目): 某配送中心进行揽货,目标客户数为50个客户,配送中心目前的运力资源如下: 问:运力怎样走法才能以最低的成本完成针对这50个客户的揽货行为 是个最优化问题(运筹学),我们只考虑简化后的模型,不考虑路面交通、时间窗口这些复杂计算,用蚁群优化算法来 阅读全文
-
snowflake算法
摘要:snowflake算法思考 缘起 为什么会突然谈到分布式唯一id呢?原因是最近在准备使用RocketMQ,看看官网介绍: 一句话,消息可能会重复,所以消费端需要做幂等。为什么消息会重复后续RocketMQ章节进行详细介绍,本节重点不在这里。 为了达到业务的幂等,必须要有这样一个id存在,需要满足下面 阅读全文
-
“拜占庭容错”、“拜占庭将军问题”
摘要:“拜占庭容错”、“拜占庭将军问题” 什么是拜占庭将军问题 接触区块链的同学,多少都听说过拜占庭将军问题,经常看到或听到某某区块链使用某某算法解决了拜占庭将军问题,那么究竟什么是拜占庭将军问题呢? 什么是拜占庭将军问题 也被称为“拜占庭容错”、“拜占庭将军问题”。拜占庭将军问题是Leslie Lamp 阅读全文
-
八大排序
摘要:八大排序算法Java实现 本文对常见的排序算法进行了总结。 常见排序算法如下: 它们都属于内部排序,也就是只考虑数据量较小仅需要使用内存的排序算法,他们之间关系如下: 稳定与非稳定: 如果一个排序算法能够保留数组中重复元素的相对位置则可以被称为是 稳定 的。反之,则是 非稳定的。 直接插入排序 基本 阅读全文
-
Consistent Hashing
摘要:深入一致性哈希(Consistent Hashing)算法原理,并附100行代码实现 本文为实现分布式任务调度系统中用到的一些关键技术点分享——Consistent Hashing算法原理和Java实现,以及效果测试。 背景介绍 一致性Hashing在分布式系统中经常会被用到, 用于尽可能地降低节点 阅读全文
-
小白算法之路-非确定性多项式(non-deterministic polynomial,缩写NP)
摘要:前端小白的算法之路 时隔多日终于解决了埋在心头的一道难题,霎时云开雾散,今天把一路而来碰到的疑惑和心得都记录下来,也算是开启了自己探索算法的大门。 问题背景 曾经有一个年少轻狂的职场小白,在前端圈子里摸爬滚打将近两年,本计划在js的道路上越走越远,以至于每天沉浸在js红皮书里不能自拔,突然有一天脑抽 阅读全文
-
团队架构实践
摘要:中小研发团队架构实践之开篇 中小型研发团队很多,而社区在中小型研发团队架构实践方面的探讨却很少。中小型研发团队特别是50至200人的研发团队,在早期的业务探索阶段,更多关注业务逻辑,快速迭代以验证商业模式,很少去关注技术架构。这时如果继续按照原有的架构及研发模式,会出现大量的问题,再也无法玩下去了。 阅读全文
-
什么是算法?
摘要:什么是算法? 算法学习(一) 不论学习有多忙,也要抽空读点书。 算法 什么是算法? 有一个很著名的公式 “程序=数据结构+算法”。 曾经跟朋友吃饭的时候我问他什么是算法,他说算法嘛,就是一套方法,需要的时候拿过来,套用就可以,我吐槽他,他说的是小学数学题的算法,不是编程的算法。 算法,从字面意义上解 阅读全文
-
身份鉴别系统
摘要:身份鉴别系统 简单来说,我们要做的就是一种通过用户敲击键盘的习惯进行身份鉴别的系统。国内外之前有一些相关研究,但是通常是数千条数据训练,而且不能随意改变敲击的字符串,或者是有的要求采用带有压力传感器的键盘,难以实用和推广。我们做一个比较简单的根据匹配相似度的系统,采用普通键盘即可使用,其算法实现很简 阅读全文
-
反转二叉树
摘要:反转二叉树 输入一个二叉树,输出其镜像。 如下图,即交换所有节点的左右子树。 这里提供两种思路:使用递归和不使用递归。 使用的二叉树定义如下: 解决方法: 算法之:翻转二叉树 事情大概是说,Max Howell 去 Google 面试,面试官说:虽然在 Google 有 90% 的工程师用你写的 H 阅读全文