在STL中,排序是个很重要的话题。1.algorithm 里的sort()只接收RandomAccessIterator用于像vector,dequeue的排序2.像set,map,这种关联式容器,本身就由RBTree维护了有序,只要遍历一遍就行了。3.而list比较特殊一点,由于只有Bidirec...
分类:
其他好文 时间:
2014-06-28 22:09:39
阅读次数:
209
1- "原地"排序-转换后替换>>> list = [2,1,3]>>> list.sort()>>> list[1, 2, 3]降序 reverse = True>>> list.sort(reverse = True)>>> list[3, 2, 1, 1]2- "复制"排序-转换然后返回>>>...
分类:
编程语言 时间:
2014-06-28 20:04:47
阅读次数:
299
几种基础排序的学习冒(冒泡)>选(选择)>插(插入)>希(希尔)>快(快速)>归(归并)>堆时间复杂度冒-O(n^2)选-O(n^2)插-O(n^2)希-O(n*logn)快-O(n*logn)归-O(n*logn)堆-O(n*logn)(1)冒泡排序:package com.jp.algorith...
分类:
其他好文 时间:
2014-06-28 17:13:40
阅读次数:
156
我们先看List.Sort()。其定义是:public void Sort( Comparison comparison )其要求传入的参数是Comparison comparison。那我们看看Comparison comparison 要求我们传入哪些参数、返回什么样的值。查阅MSDN后,我们发...
分类:
其他好文 时间:
2014-06-24 10:09:54
阅读次数:
172
Sort a linked list using insertion sort.单链表的插入排序, 考查的时单链表指针的断开和插入操作#include #include #include using namespace std;struct ListNode{ int val; List...
分类:
其他好文 时间:
2014-06-21 12:26:49
阅读次数:
206
近日学习了Shell Sort,也就是希尔排序,也称递减增量排序算法。在1959年由DL.Shell提出于1959年提出,由此得名。此版本算法是在插入排序(Insertion Sort)基础上,将数组分成了h份(gap).也就是在数组中每隔h个数取出一个数,为一个子数组。先在子数组上进行排序,然后不...
分类:
其他好文 时间:
2014-06-20 21:11:42
阅读次数:
314
1 # include 2 # include 3 # include 4 using namespace std; 5 void Sort(int a[],int b[],int c[],int n,int m) 6 { 7 int A=0, B=0, C=0; 8 while(...
分类:
其他好文 时间:
2014-06-20 16:13:08
阅读次数:
143
3,排序 默认是相关度排序。 也可以按指定的字段排序。 1 package cn.itcast.g_sort; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import org.apache.lucene....
分类:
其他好文 时间:
2014-06-20 15:39:27
阅读次数:
203
原题如下,意思就是说无序数组(由0,1,2组成),一遍扫描,把数组整理成0,1,2这样的序列。
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,...
分类:
其他好文 时间:
2014-06-18 07:12:43
阅读次数:
174
[1.1]使用库语言排序算法本文地址: http://blog.csdn.net/caroline_wendy如果不缺少内存, 可以直接使用库的排序算法.使用库语言的排序程序:C语言性能最好的算法是快速排序(quick sort).C++性能最好的是集合(set)的排序算法.C语言代码:/*
* main.cpp
*
* Created on: 2014.6.12
* Auth...
分类:
其他好文 时间:
2014-06-18 00:40:02
阅读次数:
269