自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Void of Void

Everything, is a chasing after the wind...

  • 博客(40)
  • 资源 (1)
  • 收藏
  • 关注

原创 Find the kth largest element in an unsorted array

This is should be an old problem, I had written some code long time ago. This time I just write some code for review. The idea is the same as quick sort. There are many other methods too, but this met

2016-03-11 22:30:00 686

原创 Hide an Image in Another Image

For one assignment of web programming, there is some requirement like below for hiding images, the idea idea is important to remember.So I paste the code I written before for the record.Requir

2015-12-09 15:10:05 598

原创 Document distance note

Document DistanceDocument = sequence of words-Ignore punctuation & formattingWord = sequence of alphanumeric charactersHow to define "distance"?Idea: focus on shared wordsWord

2015-09-15 18:17:43 855

原创 Peak Finding

1D Peak FindingObjectiveGiven an array A with n elements, find the index i of the peak element A[i] where A[i] >= A[i - 1]and A[i] >= A[i + 1]. For elements on the boundaries of the array, the

2015-09-15 18:12:24 1827

原创 PageRank Spark implementation

As you know, PageRank is very famous algorithm. For the detail of pagerank defination and implemenation, you can refer tohttps://en.wikipedia.org/wiki/PageRank    There are many implementa

2015-09-07 18:51:01 978

原创 Select Sort in scala

Below I written a simple select sort in scala, just for record something.object SelectSort { /* Return the index of the minimum element in the given array, index range [left, right]

2015-08-17 18:57:41 549

原创 Logical Indexing in matlab

As you know, vectorized programming has many advantage places. It's neat, effienct, sometimes it is very short and much easier than writing long tedious loops code. When manipulate matrix or data, i

2015-05-08 11:05:24 1616

原创 A matrix cheatsheet between matlab and numpy

Note: in order to use "numpy" as "np" as shown in the table, you need to import NumPy like this:import numpy as np  MATLAB/OctaveNumPyCreating Matrices (here: 3x3 mat

2014-12-03 13:16:06 1208

原创 Lowest common ancestor in binary search tree

This is a very common question

2014-09-01 16:20:40 492

原创 Higher order functions

Higher order function is great concept in

2014-06-27 17:47:08 672

原创 Concatenate pdf files with pyPdf

Sometimes there will

2014-06-19 17:03:39 577

原创 Some wrong ways to fix audio problems in Ubuntu

Just

2014-06-16 17:36:38 757

原创 Install Haskell on Ubuntu and CentOS

For Ubuntu:

2014-05-30 18:49:05 3553

原创 Ubuntu 12.04 or 13.10 root configuration

As you know root account is not

2014-05-29 14:38:21 679

原创 k Means clustering c++ implementation

KMeans is very common unsupervised learning algorithms, below is the algorithm.c++ implementation:#include #include #include #include #include using namespace std;// get the all the li

2014-01-03 18:25:02 1521

原创 Merge Sort and apply it to an interview question

Merge Sort is very efficient in sorting a list of elements with O(nlgn) complexity. It is used with divide and conquer strategy.A few days ago, I came to an interview question, the description o

2013-08-17 10:38:48 873

原创 Implement a spell checker with java

When you typing a word, many systems will suggest many words for you to select the word which you intend to type. This is spell checker.It will calculate the edit distance between a dictionary. Ever

2013-05-04 16:54:07 840

原创 Longest common subsequence problem and poj 1159 Palindrome

The longest common subsequence problem is a very basic problem in dynamic programming. If you dive in,there is manyothermethods to compute thelongest common subsequence. Hereis just the very basic

2013-04-24 12:40:18 758

原创 Parallel array summation

C++ code:#include #include #include #define NUM_THREADS 4int N;int *X;int gSum[NUM_THREADS];//pthread_mutex_t sum_mutex = PTHREAD_MUTEX_INITIALIZER;// do sumvoid *summation(void *p

2013-02-13 21:45:49 499

原创 How to install tomcat on linux

1. Downloadtomcat 7 from apache's website.    My downloaded package isapache-tomcat-7.0.32.tar.gz 2. Extract thepackage to /usr/share directory.  # tar xzvf apache-tomcat-7.0.32.tar.gz

2013-02-13 14:46:29 1544

原创 How to install eclipse on linux

1. Downloadeclipse tar package.   Download eclipse juno from eclipse's homepage to a folder. 2. Extract the tar package to /opt folder. # tar -xvzf eclipse-jee-juno-SR1-linux-gtk.tar.gz -C

2013-02-13 14:35:08 842

原创 How to install jdk 1.7 on Linux

1. Download jdk-7-linux-i586.tar.gz from Oracle'swebsite. 2. Extract tar package.   cd to the directory the tar package is downloaded.# sudo tar xzvfjdk-7-linux-i586.tar.gz   the extra

2013-02-13 14:10:00 703

原创 How to config Eclipse CDT with pthread

When compiling multithread programs in eclipse cdt, the pthread library should be configured, it is easy way. For C project.1. Project -> Properties -> C/C++ Build -> Settings -> Tool Settings ->

2013-01-13 10:52:22 1382

原创 QuickSort two way, three way partition and many other implementations

Quicksort is so famous which was honored as one of the top 10 algorithms of 20th century in science and engineer. It is use thedivide and conquer strategy. Divde the array into two subarray and recu

2013-01-08 15:19:26 3548

原创 Missionaries and Cannibals problem breadth first search implementation

Problem description:   Three missionaries and cannibals want to cross the river using a boat which can carry at most two people, under the constraint that, for both banks, if there are missionries p

2012-12-15 13:56:43 4406

原创 Simple T9 implementation with Trie

package hello.test;import java.io.*;import java.util.LinkedList;import java.util.Queue;public class Trie { private final int R = 26; // the trie branches private Node root = new N

2012-12-07 11:03:53 3113 1

原创 Disjoint set and poj 1611

package hello.test;import java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;public class DisjointSet { private final static int DEFAULT_SIZE = 10; private in

2012-11-30 17:20:56 677

原创 Incomplete checkerboard covering

Cover a checkerboard that has one corner square missing. The size of the board is usuall 2**k, use recursive way the board will bedivided into four 2**(k-1) size small board. Cover the center board

2012-11-28 15:07:35 636

原创 Sudoku backtracking with one dimension array

package hello.test;import java.io.*;import java.util.*;public class Sudoku { private static final int N = 9; // the size of the board private int[] board; // the one dimension array

2012-11-27 14:47:00 760

原创 Levenshtein's eidit distance

From Wiki, the definition of  Levenshtein distance is astring metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is equal to the numb

2012-11-24 12:06:16 530

原创 A simple bouncing ball

from graphics import *class BouncingBall(): def __init__(self, win,center, ball_radius, x, y): self.ball_circle = Circle(center, ball_radius) self.win = win self.

2012-11-22 15:33:12 1366

原创 Quick sort and the Kth number

import random# partition list L use the rightest element as pivot def partition(L, left, right): x = L[right] i = left - 1 for j in range(left, right): if L[j] < x:

2012-11-22 15:02:00 546

原创 Reverse linked list using stack and stack's implementation

class ListStack: # create an empty stack def __init__(self): self.elems = list() def isEmpty(self): return len(self) == 0 # return the number in the stack

2012-11-20 17:35:02 453

原创 Circular linked list and Josephus ring

class ListNode: def __init__(self, data): self.data = data self.next = None class CircleList: def __init__(self): self.head = None # add a no

2012-11-20 09:59:30 685

原创 N queen problem implementation in python

class NQueen: def __init__(self, n): self.n = n self.board = self.create_borad(self.n) self.queens = 0 self.row_exist = [0 for i in range(n)] # row check queen exis

2012-11-19 18:08:42 759

原创 Computing PI using Monte Carlo method

import mathimport randomclass Point(): def __init__(self, x = 0, y = 0): self.x = x self.y = y def set_rand_range(self, rand_start, rand_end): self.rand_st

2012-11-19 15:14:35 506

原创 Creating a Windows 2008 Server or Win7 without 100 MB System Reserved Partition

1.Once Windows 7 Setup is loaded, press Shirt + F10 keys at the first setup screen (which allows selection of language, keyboard and locale). A Command Prompt window will be opened.2.Run D

2012-11-15 11:09:26 559

原创 Dynamic Array Implementation in Java

package test.dynamic.array; import java.util.*; public class DynamicArray { private static final int INIT_SIZE = 1; private T[] array; // the internal array private int size = 0

2012-11-15 11:03:40 770

原创 Simple base conversion implementation use java

The stack interface defination:package test.baseconversion;public interface IStack { public abstract void push(T value); public abstract T pop(); public abstract T top(); public

2012-11-15 11:00:02 402

原创 How to Configure Eclipse for Python

Python3 must be installed before the complete instillation can be completed. If you don't have Python installed you can install it usingthese directionsInstall the PyDev plug-in for Eclipse

2012-11-15 10:59:27 1155

mergesort

mergesort java implement~!

2008-08-04

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除