本月博客排行
-
第1名
龙儿筝 -
第2名
lerf -
第3名
fantaxy025025 - johnsmith9th
- zysnba
- xiangjie88
年度博客排行
-
第1名
青否云后端云 -
第2名
宏天软件 -
第3名
gashero - wy_19921005
- vipbooks
- benladeng5225
- e_e
- wallimn
- javashop
- ranbuijj
- fantaxy025025
- jickcai
- gengyun12
- zw7534313
- qepwqnp
- 解宜然
- ssydxa219
- zysnba
- sichunli_030
- sam123456gz
- arpenker
- 龙儿筝
- tanling8334
- kaizi1992
- gaojingsong
- xpenxpen
- jh108020
- wiseboyloves
- ganxueyun
- xyuma
- xiangjie88
- wangchen.ily
- Jameslyy
- lemonhandsome
- luxurioust
- jbosscn
- mengjichen
- zxq_2017
- lzyfn123
- nychen2000
- forestqqqq
- wjianwei666
- ajinn
- zhanjia
- Xeden
- hanbaohong
- java-007
- 喧嚣求静
- kingwell.leng
- mwhgJava
最新文章列表
基础数据结构和算法六:Quick sort
Quick sort is probably used more widely than any other. It is popular because it is not difficult to implement, works well for a variety of different kinds of input data, and is substantially faster ...
基础数据结构和算法五:Merge sort
One of mergesort’s most attractive properties is that it guarantees to sort any array of N items in time proportional to N * log N. Its prime disadvantage is that it uses extra space proportional ...
基础数据结构和算法四:Shell sort
Shellsort is a simple extension of insertion sort that gains speed by allowing exchanges of array entries that are far apart, to produce partially sorted arrays that can be efficiently sorted, eve ...
Comparing two sorting algorithms
Generally we compare algorithms by
■ Implementing and debugging them
■ Analyzing their basic properties
■ Formulating a hypothesis about comparative performance
■ Running experiments to validate ...
基础数据结构和算法三:Insertion Sort
As in selection sort, the items to the left of the current index are in sorted order during the sort, but they are not in their final position, as they may have to be moved to make room for smaller i ...
基础数据结构和算法二:Selection sort
One of the simplest sorting algorithms works as follows: First, find the smallest item in the array and exchange it with the first entry (itself if the first entry is already the smallest). Then, ...
基础数据结构和算法一:UnionFind
The problem that we consider is not a toy problem; it is a fundamental computational task, and the solution that we develop is of use in a variety of applications, from percolation in physical che ...
归并排序中对小数组采用插入排序
纯归并排序的复杂度为: O(nlgn),而纯插入排序的时间复杂度为:O(n^2)。数据量很大的时候采用归并排序
但是在n较小的时候插入排序可能运行的会更快点。因此在归并排序中当子问题变得足够小时,采用插入排序来使得递归的叶子变粗可以加快排序速度。那么这个足够小到底怎么去衡量呢? 请看下面:
这么几个我不证明了,比较简单:
A,插入排序最坏情况下可以在O(nk)时间内排序每个长度为k的n/k ...
Java程序设计编程题40题(二)
6、题目:一个数如果恰好等于它的因子之和,这个数就称为 "完数 "。例如6=1+2+3.编程 找出1000以内的所有完数。
思路:在1000内通过循环判断每个数是否完数,这里又可以利用一个数最大被它的1/2整除,只需判断每
个数的前一半数。
public class WanShu {
public static vo ...
Motivating Application
1. The Internet is a graph [vertices = end hosts + routers, directed edges = direct physical or wireless connections].
2. Web graph. [vertices = web pages, edges = hyperlinks].
3. Social ne ...
Java数据结构之BitSet
BitSet是一个基于二进制位并按需增长的向量;每一个二进制位表示一个布尔值,默认为false;每一个二进制位都可以独立的修改;BitSet支持逻辑与,逻辑或及逻辑异或操作。
BitSet是通过“字数组”来实现的,目前一个“字”由8个字节组成,共64位,即2^6;目前“字”是通过long型整数来表示的。
对于给点的二进制位下标,BitSet是如何设置它的布尔值的呢?下面用一个例子来简单说明。 ...
java 加密解密简单实现[转]
感谢:http://blog.csdn.net/qiushyfm/article/details/4464512
加密算法有很多种:这里只大约列举几例:
1:消息摘要:(数字指纹):既对一个任意长度的一 ...
Notes on <<Introduction to Algorithm>> [ index ]
This is my note on reading ITA(anno.1), I start reading ITA from the end of 2010 , one year before my graduation. Lots of thinking defects exposed in reading, when I rethinked base of my ...
[leetcode] Decode ways
http://leetcode.com/onlinejudge#question_91
Decode WaysJun 25 '121292 / 5011
A message containing letters from A-Z is being encoded to numbers using the following mapping:
'A' -> 1
'B' -> 2
...
...
USACO Barn Repair 题解
题目翻译还是看USACO吧,
这题贪心,贪心都是很水的,还有解析说用动态规划做的,是因为题目太水让你脑子进水了吧?
下面是代码,忍不住用STL
/*
ID: bbsunch2
PROG: barn1
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
# ...
USACO Mixing Milk 题解
题目大意:
描述
由于乳制品产业利润很低,所以降低原材料(牛奶)价格就变得十分重要。帮助Marry乳业找到最优的牛奶采购方案。
Marry乳业从一些奶农手中采购牛奶,并且每一位奶农为乳制品加工企业提供的价格是不同的。此外,就像每头奶牛每天只能挤出固定数量的奶,每位奶农每天能提供的牛奶数量是一定的。每天Marry乳业可以从奶农手中采购到小于或者等于奶农最大产量的整数数量的牛奶。
...