• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 








每日三省吾身
 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

随笔分类 -  Algorithm + Data Structure

1 2 下一页

 
搜索数据结构
摘要:二叉查找树:平衡二叉树(AVL树):http://blog.csdn.net/kay_sprint/article/details/6676488 阅读全文
posted @ 2013-06-01 14:39 渔樵耕读2017 阅读(138) 评论(0) 推荐(0)
N皇后问题求解
摘要:用js递归了个算法: // queenNum 为皇后个数, showResult为function(arr){}函数指针 function queen(queenNum, showResult){ var arr = (function(){ var arr = new Array(queenNum); for(var i=0; i<arr.length; i++){ arr[... 阅读全文
posted @ 2013-06-01 11:42 渔樵耕读2017 阅读(278) 评论(0) 推荐(0)
另类递归
摘要:var memoizer = function (memo, fundamental) { var shell = function (n) { var result = memo[n]; if (typeof result !== 'number') { result = fundamental(shell, n); memo[n] = result; } return result; }; return shell; }; var fibonacci = memoizer([1, 1], function (shell, n) { ... 阅读全文
posted @ 2011-12-09 18:01 渔樵耕读2017 阅读(150) 评论(0) 推荐(0)
Hash算法的一点资料
摘要:http://blog.csdn.net/maddemon/article/details/6637725http://www.cnblogs.com/abatei/archive/2009/06/23/1509790.html 阅读全文
posted @ 2011-08-08 17:56 渔樵耕读2017 阅读(170) 评论(0) 推荐(0)
C# Data Structures
摘要:Array, ArrayList, List, LinkedList, Dictionary, HashSet, Stack, QueueData StructuresC#.NET has a lot of different data structures, for example, one of the most common ones is an Array. However C# come... 阅读全文
posted @ 2010-07-29 11:24 渔樵耕读2017 阅读(898) 评论(0) 推荐(0)
海量数据面试题整理
摘要:1. 给定a、b两个文件,各存放50亿个url,每个url各占64字节,内存限制是4G,让你找出a、b文件共同的url?方案1:可以估计每个文件安的大小为50G×64=320G,远远大于内存限制的4G。所以不可能将其完全加载到内存中处理。考虑采取分而治之的方法。s 遍历文件a,对每个url求取,然后根据所取得的值将url分别存储到1000个小文件(记为)中。这样每个小文件的大约为300M... 阅读全文
posted @ 2010-07-26 10:53 渔樵耕读2017 阅读(214) 评论(0) 推荐(0)
Huffman tree的C#实现
摘要:1. 结构类型定义:[代码]2. 构建树:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicstaticHuffmanTreeCreateHuffmanTree(int[]data){if(data==null||data.Length... 阅读全文
posted @ 2010-07-22 19:34 渔樵耕读2017 阅读(252) 评论(0) 推荐(0)
Binary sort tree的C#实现
摘要:1. 定义:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicclassBinarySortTree<T>whereT:IComparable{publicTData{set;get;}publicBinarySortTre... 阅读全文
posted @ 2010-07-20 13:37 渔樵耕读2017 阅读(347) 评论(0) 推荐(0)
二叉树的C#实现
摘要:1. 二叉树结构:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicclassTwoXTree{publicstringData{set;get;}publicTwoXTreeLeftChild{set;get;}publicTwoXT... 阅读全文
posted @ 2010-07-18 18:17 渔樵耕读2017 阅读(321) 评论(0) 推荐(0)
Stack和Queue的C#实现
摘要:一. Stack:1. 接口:[代码]2. 顺序栈:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicclassSequenceStack<T>:IStack<T>{privateconstintMAX_COUNT... 阅读全文
posted @ 2010-07-12 14:31 渔樵耕读2017 阅读(452) 评论(0) 推荐(0)
C#位运算及3道要求高效的算法题
摘要:在C#中可以对整型运算对象按位进行逻辑运算。按位进行逻辑运算的意义是:依次取被运算对象的每个位,进行逻辑运算,每个位的逻辑运算结果是结果值的每个位。C#支持的位逻辑运算符如下表所示。运算符号 意义 运算对象类型 运算结果类型 对象数 实例~ 位逻辑非运算 整型,字符型 整型 1 ~a& 位逻辑与运算 2 a & b| 位逻辑或运算 2 a | b^ 位逻辑异或运算 2 a ^ b&... 阅读全文
posted @ 2010-07-08 18:06 渔樵耕读2017 阅读(522) 评论(0) 推荐(0)
Josephu问题的解决方案
摘要:1. 问题描述: 设编号为1,2,…,n的n个人围坐一圈,约定编号为k(1 <=k <=n)的人从1开始报数,数到m的那个人出列,它的下一位又从1开始报数,数到m的那个人又出列,依次类推,直到所有人出列为止,由此产生一个出队编号的序列。2. 分析: 该问题可以使用多种数据结构, 但是比较简单和自然的做法是利用一个具有n个链接点且不带头接点的循环链表.3. 实现: 1) 建立... 阅读全文
posted @ 2010-07-08 14:21 渔樵耕读2017 阅读(220) 评论(0) 推荐(0)
逆转一个线性链表
摘要:1. 递归法:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--///<summary>///Reverselinkedlistbyrecursion///</summary>///<paramname="head"&... 阅读全文
posted @ 2010-07-08 14:11 渔樵耕读2017 阅读(335) 评论(0) 推荐(0)
Linear List的C#实现
摘要:1. 线性表接口:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicinterfaceILinearList<T>{//ILinearTable<T>Create(intlength);intGetLength(... 阅读全文
posted @ 2010-07-08 14:02 渔樵耕读2017
Merge Sort
摘要:实现如下:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#regionMergeSortprivatestaticvoidMerge(int[]data,intstartIndex1,intendIndex1,intstartIndex2,int... 阅读全文
posted @ 2010-03-23 17:35 渔樵耕读2017 阅读(234) 评论(0) 推荐(0)
Heap Sort
摘要:堆积排序是对直接选择排序的一种改进,具体实现如下:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--     #regionHeapSortprivatestaticvoidAdjust(int[]data,introotIndex,intlastI... 阅读全文
posted @ 2010-03-23 15:52 渔樵耕读2017 阅读(189) 评论(0) 推荐(0)
Shell's Sort
摘要:谢尔排序又称减小增量排序法,是对直接插入排序法的改进。具体实现如下:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--///<summary>///谢尔排序///</summary>///<paramname="data... 阅读全文
posted @ 2010-03-23 14:32 渔樵耕读2017 阅读(158) 评论(0) 推荐(1)
Selection Sort
摘要:选择排序法核心思想是:每一趟排序选择未排序元素中最小元素作为已排序部分的一个新元素。具体实现如下:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--///<summary>///选择排序///</summary>///<... 阅读全文
posted @ 2010-03-22 17:43 渔樵耕读2017 阅读(151) 评论(0) 推荐(0)
Quick Sort
摘要:快速排序是对冒泡排序的一种改进。它基于分治策略,对于要排序的一个序列,从中选一值进行排序,将其放入到正确的位置position。然后以position为界,对左右两部分再分别做排序。直到划分的长度为1。具体实现如下:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighte... 阅读全文
posted @ 2010-03-22 15:32 渔樵耕读2017 阅读(206) 评论(0) 推荐(0)
C#的Convert.ToInt32实现
摘要:以下是Convert.ToInt32(String str)的个人实现:代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicclassConvertHelper{privateconstintPOSITIVE_SIGN_NUM=43;pr... 阅读全文
posted @ 2010-03-19 18:02 渔樵耕读2017 阅读(362) 评论(0) 推荐(0)
 

1 2 下一页