会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
南郭子綦
leetcode一些习题的python解答,约160道左右。 《算法导论》一些算法的实现。
博客园
首页
新随笔
联系
管理
订阅
2015年8月20日
[sicp]huffman编码的实现 @ Scheme
摘要: #lang racket(define (length items) (if (null? items) 0 (+ 1 (length (cdr items)))))(define (element-of-set? x set) (cond ((null? set) fals...
阅读全文
posted @ 2015-08-20 17:05 南郭子綦
阅读(836)
评论(0)
推荐(0)
2015年3月17日
[算法导论]拓扑排序 @ Python
摘要: class Graph: def __init__(self): self.V = []class Vertex: def __init__(self, x): self.key = x self.color = 'white' s...
阅读全文
posted @ 2015-03-17 16:54 南郭子綦
阅读(1491)
评论(0)
推荐(0)
2015年3月16日
[算法导论]强连通分量 @ Python
摘要: class Graph: def __init__(self): self.V = []class Vertex: def __init__(self, x): self.key = x self.color = 'white' s...
阅读全文
posted @ 2015-03-16 22:32 南郭子綦
阅读(1044)
评论(0)
推荐(0)
[算法导论]DFS @ Python
摘要: class Graph: def __init__(self): self.V = []class Vertex: def __init__(self, x): self.key = x self.color = 'white' s...
阅读全文
posted @ 2015-03-16 15:43 南郭子綦
阅读(1675)
评论(0)
推荐(0)
[算法导论]哈希表 @ Python
摘要: 直接寻址方式:class HashTable: def __init__(self, length): self.T = [None for i in range(length)]class Data: def __init__(self, key, satelite_da...
阅读全文
posted @ 2015-03-16 11:59 南郭子綦
阅读(611)
评论(0)
推荐(0)
2015年2月10日
[算法导论]BFS @ Python
摘要: class Graph: def __init__(self): self.V = []class Vertex: def __init__(self, x): self.key = x self.color = 'white' s...
阅读全文
posted @ 2015-02-10 14:59 南郭子綦
阅读(715)
评论(0)
推荐(0)
[算法导论]迪克斯特拉算法 @ Python
摘要: class Graph: def __init__(self): self.V = [] self.w = {}class Vertex: def __init__(self, x): self.key = x self.color...
阅读全文
posted @ 2015-02-10 14:54 南郭子綦
阅读(1354)
评论(0)
推荐(0)
2015年2月4日
[算法导论]红黑树实现(插入和删除) @ Python
摘要: class RBTree: def __init__(self): self.nil = RBTreeNode(0) self.root = self.nilclass RBTreeNode: def __init__(self, x): sel...
阅读全文
posted @ 2015-02-04 15:40 南郭子綦
阅读(2929)
评论(0)
推荐(0)
2015年1月27日
[算法导论]二叉查找树的实现 @ Python
摘要: 《算法导论》第三版的BST(二叉查找树)的实现:class Tree: def __init__(self): self.root = None# Definition for a binary tree nodeclass TreeNode: def __init__(...
阅读全文
posted @ 2015-01-27 14:50 南郭子綦
阅读(1192)
评论(0)
推荐(0)
2014年11月12日
[leetcode] Min Stack @ Python
摘要: 原题地址:https://oj.leetcode.com/problems/min-stack/解题思路:开辟两个栈,一个栈是普通的栈,一个栈用来维护最小值的队列。代码:class MinStack: # @param x, an integer def __init__(self): ...
阅读全文
posted @ 2014-11-12 12:10 南郭子綦
阅读(5873)
评论(0)
推荐(0)
2014年10月23日
[leetcode]Find Minimum in Rotated Sorted Array II @ Python
摘要: 原题地址:https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/解题思路:这道题和上一道题的区别是,数组中可能有相同的数。那么,分下列几种情况:代码:class Solution: # @param n...
阅读全文
posted @ 2014-10-23 14:26 南郭子綦
阅读(2718)
评论(0)
推荐(1)
[leetcode]Find Minimum in Rotated Sorted Array @ Python
摘要: 原题地址:https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/解题思路:话说leetcode上面的二分查找题目真的不少啊。下图是这道题的数组的两种情况,分别去处理就可以了。class Solution: #...
阅读全文
posted @ 2014-10-23 14:22 南郭子綦
阅读(2874)
评论(0)
推荐(0)
2014年10月11日
[leetcode]Maximum Product Subarray @ Python
摘要: 原题地址:https://oj.leetcode.com/problems/maximum-product-subarray/解题思路:主要需要考虑负负得正这种情况,比如之前的最小值是一个负数,再乘以一个负数就有可能成为一个很大的正数。代码:class Solution: # @param A...
阅读全文
posted @ 2014-10-11 16:32 南郭子綦
阅读(3738)
评论(0)
推荐(0)
业余办一个【编程语言+数据结构+算法】培训班怎么样?
摘要: 缘起:计算机技术在未来将会很重要,所以想业余做一些培训的事情,以前在公司也做过培训编程的事情,有这方面的经验。而数据结构与算法的重要性不言而喻了。编程语言选用python,上手速度快,学会以后能迅速开始学习数据结构与算法。数据结构与算法的教材选用《算法导论》。习题选自leetcode。不教很变态的算...
阅读全文
posted @ 2014-10-11 12:19 南郭子綦
阅读(1933)
评论(4)
推荐(1)
2014年8月17日
[算法导论]merge sort @ Python
摘要: import sysclass mergesort(): def merge_sort(self, A, p, r): if p < r: q = (p + r) / 2 self.merge_sort(A, p, q) ...
阅读全文
posted @ 2014-08-17 15:17 南郭子綦
阅读(1140)
评论(0)
推荐(1)
下一页
公告