??
冒泡排序即每次遍历。相邻数字间进行比较,前者大于后者进行交换,不断将最大值后移,直至沉至最后位置;算法关键要点在于确定每次循环的边界;
后面两种算法则是对冒泡排序一定程度上的改良,但相对于其他排序算法,冒泡排序性能依然较差。
//冒泡排序
public class Bubble_Sort {
//最原始的解法
public void bubble_sort1(int[] ...
分类:
编程语言 时间:
2015-03-15 10:59:38
阅读次数:
153
1.两个有序数组组合成一个新的有序数组<?php$arr1=array(2,5,7,9,12);$arr2=array(3,4,6,8,10,11);function merge_sort($arr1,$arr2){ $len1=count($arr1); $len2=count($ar...
分类:
编程语言 时间:
2015-03-15 10:46:14
阅读次数:
217
1.题目Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers ...
分类:
其他好文 时间:
2015-03-14 23:19:13
阅读次数:
238
var ary = [8,9,10,3], compare = function(a,b){ return b.age-a.age; }, g = [ { name:"jim", age:29 }, { name:"tom", age:15 ...
分类:
编程语言 时间:
2015-03-14 15:15:19
阅读次数:
125
Insertion Sort List问题:Sort a linked list using insertion sort.思路: 三行情书 旧旧 新 旧 旧 新我的代码:/** * Definition for singly-linked list. * public class ListNod....
分类:
其他好文 时间:
2015-03-14 13:43:02
阅读次数:
114
http://acm.hdu.edu.cn/showproblem.php?pid=2037这道题乍看上去不知道从何处入手,其实只要将节目的时间从前到后排个序就可以了,注意是按结束时间的先后排序,排序方法和上次一样,建立一个结构体用sort函数排序。然后暴力求解:假设前一个节目要看完,记录下结束时间...
分类:
其他好文 时间:
2015-03-14 12:26:24
阅读次数:
105
sort用来排序,uniq用来去重,这两个命令经常被结合在一起使用.主要就是因为uniq去重的前提是文本必须排好序才可以.
当然字面上面理解,这两个命令的确是这样的功能.但是其实不然,他们还有相关的其它能力.一起来看看.
sort [option] filename ......
分类:
系统相关 时间:
2015-03-13 23:50:27
阅读次数:
318
Robotic SortTime Limit: 6000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) 【Problem Description】Somewhere deep in the Czech Technical...
分类:
其他好文 时间:
2015-03-13 20:25:11
阅读次数:
156
/**
* 给两组数,各n个。
* 请调整每组数的排列顺序,使得两组数据相同下标元素对应相乘,然后相加的和最小。
*/
import java.util.*;
import java.io.*;
public class 最小乘积 {
public static void JianArray(Integer[] b1) {
Arrays.sort(b1);
in...
分类:
其他好文 时间:
2015-03-13 14:27:57
阅读次数:
121