自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

原创 关于“simplicity”的看法 -- 读《Masterminds of Programming》有感

任何编程语言,都是解决实际问题的工具。我想,没有那个语言的创始人只希望他的语言是同行的热点话题,却很少有程序员去使用它。所以我想,从解决实际问题的角度出发,去看待语言的“简单”,我们能得到很多启示。那么我对“简单”的看法是什么呢?我一一列举:1、简单不是一个独立概念,它必然是相对复杂而言的。当我们定义了简单,我们也就定义了复杂。反过来也如此,定义了复杂也就定义了简单;2、《Co

2016-01-24 12:11:18 517

原创 Presorting

Exercises 6.11def min_diff(L): n = len(L) if n > 1: L = sorted(L) md = L[1] - L[0] i = 2 while i < n: d = L[i] - L[i - 1] if

2016-01-12 20:25:09 605

原创 The Maximum-Subarray Problem

Suppose that you have been offered the opportunity to invest in the Volatile Chemical Corporation. Like the chemicals the company produces, the stock price of the Volatile Chemical Corporation is rath

2015-12-27 23:18:09 749

原创 Use python to implement Dijkstra's algorithm

The implementation of the Dijkstra's Algorithm:def dijkstra(g, s): from priority_queue import PriorityQueue, less_than result = [] class Record: def __init__(self, v, parent = -

2015-12-25 20:56:40 371

原创 必须认真学习的算法书

必须认真学习的算法书

2015-03-26 22:44:30 5648

原创 Two ways to solve the "Longest common subsequence" problem

namespace v1 { template std::basic_string lcs(const CHAR * s1, const CHAR * s2) { typedef std::basic_string String; String ret; int m =

2015-02-27 16:53:26 428

原创 Implement most-significant-digit-first string sort

namespace pratique{ namespace details { const size_t CUTOFF = 15; int compare(const char * s1, const char * s2, size_t d) { int ret = 0; s1 +=

2015-01-20 16:37:21 593

原创 How to implement segment tree

template class segment_tree { struct record { int left; int right; T value; T sum; }; int m_siz

2015-01-18 17:53:53 463

原创 Three ways to solve the "Longest Palindromic Substring" problem

namespace v1 { namespace details { inline bool is_palindromic(int i, int j, std::vector>> & cache) { std::pair deux = cache[i][j];

2015-01-11 00:12:05 444

原创 How to solve the Candy problem?

The problem is:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child mu

2015-01-09 15:34:04 460

原创 Give an O(log m + log n) algorithm to find the kth element in two sorted arrays

Give an O(log (m+n)) algorithm to find the kth element in two sorted arrays A and B of size m and n respectively as if they are merged.namespace details{ template I kth_element( I b1, I

2015-01-09 01:59:10 530

原创 Use Python to implement Trie

class TrieKeyIterator: def __init__(self, root): self.root = root self.root_list = {'' : self.root} self.stack = [(iter(self.root_list.items()), '')] def __next__(self

2014-11-03 22:01:23 630

原创 What is the probability that you hire exactly twice?

In HIRE-ASSISTANT, assuming that the candidates are presented in a random order,

2014-09-01 14:30:39 3430

原创 Efficiently factor N when e and d become known to you.

The problem is:In the RSA cryptosystem, Alice’s public key (N, e) is available to everyone. Suppose that her private key d is compromised and becomes known to Eve. Show that if e = 3 (a common choic

2014-08-24 10:26:26 1586

原创 Implement regular expressions

namespace details { void dfs_visit( size_t u, std::vector> & g, std::vector & visited ) { visited[ u ] = true; for ( auto i = g[ u ].begin(), e = g[ u ] .en

2014-06-08 21:42:47 697

原创 Recursion problems

Problem : print out all of the permutations of n elements:

2014-05-03 09:08:57 478

原创 Implement the avl tree, rbtree without the two fields: parent pointer and balance/color

#ifndef GYM_RED_BLACK_TREE_H_6D4EBDB0_5B18_4FC1_A34A_CBBF36FE95E4#define GYM_RED_BLACK_TREE_H_6D4EBDB0_5B18_4FC1_A34A_CBBF36FE95E4#include #include #include #include #include #include #includ

2014-02-13 16:54:49 716

原创 Give an O(lg n)-time algorithm to find the median of all 2n elements in arrays X and Y.

Let X[1 ‥ n] and Y[1 ‥ n] be two arrays, each containing n numbers already in sorted order. Give anO(lg n)-time algorithm to find the median of all 2n elements in arraysX and Y. template

2013-08-27 16:08:05 1327

原创 Implement the quicksort algorithm in as many different ways as possible

#ifndef GYM_ALGORITHM_QUICK_SORT_H_6D4EBDB0_5B18_4FC1_A34A_CBBF36FE95E4#define GYM_ALGORITHM_QUICK_SORT_H_6D4EBDB0_5B18_4FC1_A34A_CBBF36FE95E4#include #include "sort_common.h"#include "inser

2012-10-31 11:10:16 598

原创 If only one side of processes crash, the other side of processes do not hang.

Use the shared memory to implement a queue, and producers can use it to transfer data to consumers. If only one side of processes crash, the other side of processes do not hang. The interface is:

2012-08-27 16:19:14 622

原创 Reverse a doubly linked list in O(1) time

#ifndef GYM_CLRS_V3_10_2_8_LINKED_LIST_H_6D4EBDB0_5B18_4FC1_A34A_CBBF36FE95E4#define GYM_CLRS_V3_10_2_8_LINKED_LIST_H_6D4EBDB0_5B18_4FC1_A34A_CBBF36FE95E4#include #include #include names

2012-08-12 20:30:19 1227

空空如也

空空如也

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

TA关注的人

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