原创 [碩.Love Python] BinomialHeap(B堆 & 二項堆)

class Node(object):     def __init__(self, data):         self.data = data         self.child = None         self.left =

原创 [碩.Love Python] 高斯N皇后問題(回溯法)

八皇后問題是高斯於1950年提出的,這是一個典型的回溯算法的問題。八皇后問題的大意如下:國際象棋的棋盤是8行8列共64個單元格,在棋盤上擺件八個皇后,使其不能互相***,也就是說任意兩個皇后都不能處於同一行、同一列或同一斜線上。問總共有多少

原创 [碩.Love Python] MergeSort(歸併排序)

def merge(s, d, i, m, n):     # merge [i, m) [m, n)     j, k = m, i     while i < m and j < n:         if s[i] < s[j]:

原创 [碩.Love Python] QuickSort(快速排序)

def partition(a, i, j):     k = -1     while True:         while k * (a[i] - a[j]) >= 0:             if i == j:         

原创 [碩.Love Python] InsertionSort(插入排序)

def insertionSort(a):     for i in xrange(1, len(a)):         t = a[i]         for j in xrange(i, 0, -1):             if

原创 [碩.Love Python] FibonacciHeap(F堆 & 斐波那契堆)

class Node(object):     __slots__ = [         'data', 'child', 'left', 'right',         'degree', 'parent', 'childCut',

原创 [碩.Love Python] HeapSort(堆排序)

def adjust(a, root, n):     k = a[root-1]     c = root * 2     while c <= n:         if c + 1 <= n and a[c] > a[c-1]:  

原创 [碩.Love Python] RadixSort(基數排序)

def radixSort(a, n):     rl = [[] for _ in xrange(10)]     for i in xrange(n):         t = 10 ** i          for j in xr

原创 如何學習Python?

Python上手很容易, 基本有其他語言編程經驗的人可以在1周內學會Python最基本的內容.它們包括:1.常用內置類型(int, float, bool, bytes, str, list, dict, set)的使用.2.分支if-el

原创 [碩.Love Python] Heap(堆)

class MinHeap(object):     def __init__(self, iterable=()):         self.array = [None]         self.array.extend(iterab

原创 [碩.Love Python] BinarySearchTree(二叉搜索樹)

class Node(object):     __slots__ = ['left', 'right', 'data']     def __init__(self, data, left=None, right=None):     

原创 [碩.Love Python] HeapSort(堆排序)

def adjust(a, root, n):     k = a[root-1]     c = root * 2     while c <= n:         if c + 1 <= n and a[c] > a[c-1]:  

原创 [碩.Love Python] 高斯N皇后問題(回溯法)

八皇后問題是高斯於1950年提出的,這是一個典型的回溯算法的問題。八皇后問題的大意如下:國際象棋的棋盤是8行8列共64個單元格,在棋盤上擺件八個皇后,使其不能互相***,也就是說任意兩個皇后都不能處於同一行、同一列或同一斜線上。問總共有多少

原创 [碩.Love Python] FibonacciHeap(F堆 & 斐波那契堆)

class Node(object):     __slots__ = [         'data', 'child', 'left', 'right',         'degree', 'parent', 'childCut',

原创 [碩.Love Python] InsertionSort(插入排序)

def insertionSort(a):     for i in xrange(1, len(a)):         t = a[i]         for j in xrange(i, 0, -1):             if