Python
文章平均质量分 82
williamcs
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
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 · 720 阅读 · 0 评论 -
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 · 1961 阅读 · 0 评论 -
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 · 1069 阅读 · 0 评论 -
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 · 1335 阅读 · 0 评论 -
Concatenate pdf files with pyPdf
Sometimes there will原创 2014-06-19 17:03:39 · 651 阅读 · 0 评论 -
Higher order functions
Higher order function is great concept in原创 2014-06-27 17:47:08 · 740 阅读 · 0 评论 -
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 · 949 阅读 · 0 评论 -
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 · 839 阅读 · 0 评论 -
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 · 619 阅读 · 0 评论 -
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 · 1434 阅读 · 0 评论 -
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 · 525 阅读 · 0 评论 -
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 · 560 阅读 · 0 评论 -
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 · 845 阅读 · 0 评论 -
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 · 758 阅读 · 0 评论 -
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 · 1232 阅读 · 0 评论 -
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 · 995 阅读 · 0 评论
分享