- 博客(8)
- 收藏
- 关注
原创 CareerCup 5.7
An array A[1...n] contains all the integers from 0 to n except for one number which is missing. In this problem, we cannot access an entire integer in A with a single operation. The elements of A ar
2013-02-26 17:12:03 239
原创 Divide & Conquer: Integer Multiplication
D & C reference: http://www.cs.berkeley.edu/~vazirani/algorithms/chap2.pdf 中文参考: http://www.gdcp.cn/jpkc/sjjg/app/jm/bignumber_mul/solution.htm
2013-02-25 13:39:56 548
原创 Divide & Conquer : Closest Pair Algo
Reference: http://www.cs.ucsb.edu/~suri/cs235/ClosestPair.pdf
2013-02-25 12:12:04 219
原创 Sequence Alignment
伪码 Pseudo Code 代码 #include #include using namespace std; int alpha(char c1, char c2) { if(c1 == c2) return 0; else return 1; } int minThree(int a, int b, int c) { int temp; if(a < b)
2013-02-23 06:13:34 344
原创 Bellman-Ford
求Graph里两点间最短距离,可以容纳负值边;可以检测出negative circle int bellmanFord(int n[][N], int start, int dest) { int dist[N]; int path[N]; int i, j, k; for(i = 0; i < N; i++) { dist[i] = -1; } dist[dest]
2013-02-21 16:33:47 179
原创 CareerCup 17.12 Pair sum equal to a fixed value
第一种方法建立哈希表 第二种方法,利用ordered array线性检测 /* * Question 17.12 */ public void pairSum(int[] nums, int sum) { Arrays.sort(nums); // Array Class static function int first = 0, last = num
2013-02-19 18:23:49 216
原创 Quick Sort
#include using namespace std; /* * choose the first element as pivot */ int partition(vector &v, int start, int end) { int pivot = v[start]; int left = start + 1; int right = end; while (tru
2013-02-12 17:07:09 145
原创 Merge Sort
The basic idea of Merge Sort can be outlined as follows: 1. Check to see if the vector is empty or has only one element. If so, it must already be sorted, and the function can return without do
2013-02-12 15:52:49 179
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人