算法分析
MyHuster
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
冒泡排序
# coding:utf-8__author__ = 'taohao'"""bubble sort"""def bubble_sort(array): i = j = 0 length = len(array) while i < length-1: while j < length-i-1: if array[j] >原创 2015-03-15 10:59:14 · 403 阅读 · 0 评论 -
堆排序以及二叉堆的一些操作
注意: 此文中的二叉堆默认为最小二叉堆此处的堆排序是降序排序原创 2015-03-15 16:47:44 · 526 阅读 · 0 评论 -
快速排序
def quick_sort(array, left, right): if left < right: # the if is necessary. only when left < right, the recursion can be handled i = left j = right tem = array[left]原创 2015-03-14 15:50:41 · 408 阅读 · 0 评论 -
归并排序
# coding:utf-8__author__ = 'taohao'""" merge sort use the extra space to exchange the time when merge two arrays, we need to use another empty array to store the completed array so the p原创 2015-03-14 17:12:20 · 490 阅读 · 0 评论 -
插入排序
# coding:utf-8__author__ = 'taohao'"""insert sort"""def insert_sort(array): i = 1 while i < len(array): tem = array[i] j = i while tem 0: array[j] =原创 2015-03-14 18:19:35 · 464 阅读 · 0 评论 -
shell 排序
# coding:utf-8__author__ = 'taohao'"""shell sort is improving the performance of the insert sort"""def shell_sort(array): gap = len(array)/2 while gap > 0: i = gap while原创 2015-03-14 18:35:45 · 536 阅读 · 0 评论 -
java 统计10000篇文章中不同单词出现的次数并以次序排序
统计10000篇文章中不同单词出现的次数并以次序排序此次统计从两方面入手:一是单线程读取10000个文件;二是打开10000个线程,每个线程读取一个文件单线程程序import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.util.ArrayList;im原创 2015-05-14 22:10:14 · 1780 阅读 · 0 评论 -
Hadoop 实现矩阵相乘
Hadoop 实现矩阵相乘包括两点:1、mapreduce实现矩阵相乘2、python脚本生成矩阵hadoop com.sun.tools.javac.Main MatrixMutiply.java jar cf matrix.jar MatrixMutiply*.classhadoop fs -rm -r /matrixoutput # 只是在再次运行时需要删掉上一次运行时生成的文件hadoop jar matrix.jar MatrixMutiply /matrixinput/*原创 2015-06-12 15:49:34 · 4449 阅读 · 3 评论
分享