BACKGROUNDA Virtual Machine (VM) is an efficient, isolated duplicate of a real computer system. More than one VM may be provided concurrently by a sin...
分类:
其他好文 时间:
2014-06-28 14:27:00
阅读次数:
433
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime co...
分类:
其他好文 时间:
2014-06-28 13:44:09
阅读次数:
188
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is not found ...
分类:
其他好文 时间:
2014-06-22 21:47:15
阅读次数:
269
Given an index k, return the
kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only
O(k) extra space?
...
分类:
其他好文 时间:
2014-06-22 21:31:26
阅读次数:
214
最近学习了c++primer中的第11章的泛型算法,这一章的基础是c++中的容器,但是泛型算法是独立于特定的容器的,这样的算法不会改变容器的大小,这样保证了不管是哪种类型的容器都可以同时调用同一种算法来实现操作。
首先介绍下这些常用的算法的头文件,比较常用的是algorithm,numeric和iterator,最先遇到的函数是find()函数,需要三个参数,前两个是一般的算法函数都需要的,是一...
分类:
编程语言 时间:
2014-06-22 16:57:43
阅读次数:
277
无向图最小生成树的Prim算法,在实现上方法各异。本文演示了用Python是实现的方法,特别是应用了Python有的一个heapq排序方法,让代码更简洁。...
分类:
其他好文 时间:
2014-06-22 16:11:00
阅读次数:
176
题目要求:
Input a value n, then print out a N×N matrix.
Example 1: Input 2, then
1 2
4 3
Example2: Input 4, then
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
Please write a program to...
分类:
其他好文 时间:
2014-06-22 00:38:02
阅读次数:
409
因为在这里发文章的时候,莫名其妙的出现发布出去的问题,客服告知是因为链接或者敏感词。
能不能告诉我哪里出了问题?我可以修改,以便再发。
但是,没有人告诉我,只是告诉我不能发。
另外,能不能公布一下敏感词?以后我在遣词造句的时候,才可以避免。
但是,没有看到敏感词列表。
以后我的文章将发布在https://www.github.com/qiwsir/algorithm里面,有兴趣的可以到那...
分类:
编程语言 时间:
2014-06-21 23:08:09
阅读次数:
211
问题
最短路径问题的Dijkstra算法
是由荷兰计算机科学家艾兹赫尔·戴克斯特拉提出。迪科斯彻算法使用了广度优先搜索解决非负权有向图的单源最短路径问题,算法最终得到一个最短路径树> 。该算法常用于路由算法或者作为其他图算法的一个子模块。
这个算法的python实现途径很多,网上能够发现不少。这里推荐一个我在网上看到的,本来打算自己写,看了这个,决定自己不写了,因为他的已经太...
分类:
其他好文 时间:
2014-06-21 20:58:46
阅读次数:
183
package com.jp.algorithm.sort;/** * 假设我们要对0-7内的5个元素(4,7,2,5,3)排序(这里假设这些元素没有重复)。那么我们就可以采用Bit-map的方法来达到排序的目的。要表示8个数 * ,我们就只需要8个Bit(1Bytes),首先我们开辟1Byte的空...
分类:
其他好文 时间:
2014-06-21 16:20:21
阅读次数:
352