亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gamasort.cpp

?? this is source code for gamasort algorithm in c++ language
?? CPP
字號:
/*
 * Gamasort: from Joseph Gama
 *
 * This is a Radix Sort Exchange routine which will work only on
 * unsigned integers (unlike a general sorting function which
 * works based on comparisons).  Since its complexity overhead
 * is pretty large, it is efficient on big array where the
 * maximum number is bounded by a relatively small ceiling.
 * E.g. a big array of bytes or shorts.
 * 
 * The algorithm is pretty simple:
 * 1) It will first find the maximum and minimum radices in order to see
 *    if it can skip some radices.  Then it proceeds to order
 *    from the numbers with the most-significant set-bit downwards
 * 2) It leaves the unsorted segments of length == CUTOFF unsorted.
 * 3) From higher bit to lower it will compare numbers
 *    based on the bit being scanned.  This process is
 *    improved by using 2 pivots that will move 0's to the
 *    left and 1's to the right.
 * 4) When finding the pivots it looks for the best case
 *    of all 0's or 1's to skip more scanning.
 * 5) A low overhead Insertion Sort finishes the job.
 *
 * To make it an O(n*log(n)) algorithm in which the 'n'
 * is proportional to the largest number in the sorted array
 * requiers commenting            Call InSort(t(), 1, up)
 * and also commenting            (up-lo>CUTOFF)AND
 * Which is clearly detailed in the code
 *
 * in this version, instead of including sort.h, SWAP and Insort were taken from
 * "A library of internal sorting routines" by Ariel Faigon
 * (http://www.yendor.com/programming/sort/)
 *
 *
 *this file compiled and executed fine on both GNU () and Microsoft (VC++)
 */

#include <iostream.h>
#include <stdlib.h>
//in this version, instead of including sort.h, SWAP and Insort were taken from 
//"A library of internal sorting routines" by Ariel Faigon
//(http://www.yendor.com/programming/sort/)

#define SWAP(x, y) temp = (x); (x) = (y); (y) = temp//Swaps the contents of 2 variables
#define GT(x, y) ((x) > (y))//Greater Than
#define CUTOFF 15 //above this number there will be 2 recursive calls with 2 sub arrays
#define ArrayDimension 100000 //how many numbers to be tested

void verify (int a[],int i, int j)
{
	int x, IndexError;
		for (x=i;x<j;x++)
		{
			IndexError=x;
			if (a[x]>a[x+1])
				break;		
			}
	if (IndexError == j-1)
		cout<<"Array sorted properly!"<<endl;	
	else
		cout<<"ERROR, array not sorted properly!"<<endl;
}

void  insort (int array[], int len)
{
	register int	i, j;
	register int	temp;

	for (i = 1; i < len; i++) {
		/* invariant:  array[0..i-1] is sorted */
		j = i;
		/* customization bug: SWAP is not used here */
		temp = array[j];
		while (j > 0 && GT(array[j-1], temp)) {
			array[j] = array[j-1];
			j--;
		}
		array[j] = temp;
	}
}

//
// Recursive version of GamaSort
//
static void GamaSort( int array[], int lo, int up, int lbit, int ubit )
//lo and up are the indexes of the sub-array to be ordered
//lbit is lowest bit to be scanned, if all elements of the array are >8, lbit=3
//ubit is the current bit being scanned
{
	register int	temp;
    register long	b, r, l;
	//b is the integer that is 2 to the power of the current bit being scanned
	//r is the index of the right pivot
	//l is the index of the left pivot
	if ((up-lo>CUTOFF)&&(ubit>=lbit)){//(up-lo>CUTOFF)&& can be removed if k log n is desired for all cases
		//keep going only if 
		//a)the sub-array is greater than the cutoff point
		//b)the current bit is not smaller than the lowest bit
		b=(1<<ubit);//b=2^ubit
		r=up;l=lo;//2 pivots
		while(((b & array[r])==b)&&(r>lo))
			r--;//check 1's from the right
		if (!((r==lo)&&((b & array[r])==b)))
			while(((b & array[l])==0)&&(l<up))l++;//check 0's from the left
		if(((r==lo)&&((b & array[r])==b))||((l==up)&&((b & array[l])==0)))
			GamaSort(array, lo, up, lbit, ubit-1);//if it's all 0's or 1's, skip it
		else{
			//this is where the swapping occurs
			while(l<r){
				if(((b & array[l])==b)&&((b & array[r])==0)){
					SWAP(array[r],array[l]);
					while(((b & array[r])==b)&&(r>lo))
						r--;
				}
			l++;
		}
		if (l>=r)
			r++;
		//recursivelly sort the 2 blocks corresponding to the sorted 
		//sub-arrays but now for a lower radix
		if(r-1>lo)
			GamaSort(array, lo, r-1, lbit, ubit-1 );//left
		if (up>r)
			GamaSort(array, r, up , lbit, ubit-1 );//right
	}
	}
}

//
// Main version of gamasort (call this one)
//
void GamaSortStarter( int  array[], int up )
{
	register int  i,ubit=1,counter,n=0,lbit=0,l=1;
	for (counter=0;counter<=up;counter++)
		n|=array[counter];
	if((n & 1)==0){
		i=1;
		while((n & (1<<i))==0)i++;
		lbit=i;
	}
	while((1<<ubit)<=n)
		ubit++;
	ubit--;
	GamaSort(array, 0, up, lbit,ubit);
	insort(array, up);//if (up-lo>CUTOFF)&& was removed then this line should be removed as well
						//if k log n is desired for all cases
}

main()
{
	int c,array[ArrayDimension];
	for(c=0;c<ArrayDimension;c++)
		array[c]=rand();
	GamaSortStarter(array,ArrayDimension);
	verify(array,0,ArrayDimension);
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品人成在线观看免费| 欧美精品欧美精品系列| 日本大胆欧美人术艺术动态| 尤物视频一区二区| 亚洲美女免费视频| 成人免费在线视频| 亚洲激情综合网| 一区二区三区四区激情| 一区二区三区久久久| 亚洲精品综合在线| 亚洲综合色婷婷| 日本美女一区二区三区视频| 美女视频黄 久久| 国产麻豆成人传媒免费观看| 成人精品高清在线| 欧美在线你懂得| 91精品国产综合久久国产大片| 日韩一级片网站| 国产无人区一区二区三区| 国产精品美女一区二区在线观看| 国产精品久久久久久久久图文区| 亚洲四区在线观看| 水蜜桃久久夜色精品一区的特点| 免费精品视频在线| 成人国产精品免费观看动漫| 欧美性视频一区二区三区| 欧美日韩成人高清| 国产日韩欧美制服另类| 一区二区三区四区在线| 美女在线视频一区| 97se亚洲国产综合自在线观| 欧美一区二区三区视频在线观看 | 日日摸夜夜添夜夜添国产精品| 丝瓜av网站精品一区二区| 国产在线精品一区二区三区不卡| 99久久免费视频.com| 日韩一区二区在线观看| 1024成人网| 欧美96一区二区免费视频| 丁香啪啪综合成人亚洲小说 | 久久久99精品免费观看不卡| 尤物在线观看一区| 国产在线视频一区二区三区| 色婷婷精品久久二区二区蜜臀av| 欧美成人性福生活免费看| 中文无字幕一区二区三区| 日韩精品电影一区亚洲| 99久久99久久久精品齐齐| 欧美电视剧免费全集观看| 亚洲精品综合在线| 国产成人在线看| 欧美精品日韩一区| 一区二区三区四区在线免费观看| 国产一二三精品| 日韩一区二区三区观看| 亚洲一卡二卡三卡四卡| 成人aaaa免费全部观看| 久久综合色综合88| 日本不卡的三区四区五区| 在线免费观看不卡av| 欧美激情一区二区三区在线| 久久99精品视频| 欧美一区二区三区视频| 亚洲va天堂va国产va久| 91麻豆福利精品推荐| 国产精品无码永久免费888| 精品一区精品二区高清| 欧美一区二区三区免费视频| 亚洲午夜在线观看视频在线| 91免费看片在线观看| 亚洲丝袜精品丝袜在线| av电影在线不卡| 国产精品久久久久久久久久免费看| 国模套图日韩精品一区二区| 日韩免费高清av| 麻豆精品一区二区三区| 精品国产伦一区二区三区免费 | 成人午夜在线视频| 久久久久久久久97黄色工厂| 激情文学综合丁香| 久久综合九色综合97婷婷| 极品少妇一区二区| 久久综合色婷婷| 成人精品国产福利| 亚洲欧洲精品一区二区三区| jlzzjlzz欧美大全| 亚洲男同1069视频| 欧美日本一区二区三区四区| 五月婷婷综合网| 91精品国产综合久久久久久久久久 | 欧美国产综合色视频| 成人综合在线网站| 亚洲视频小说图片| 欧美日韩国产美女| 久久66热re国产| 国产精品乱人伦| 欧美亚洲精品一区| 狠狠色丁香婷婷综合| 国产精品乱码一区二区三区软件 | 午夜在线电影亚洲一区| 欧美一区二区三区思思人| 国产麻豆精品95视频| 中文字幕人成不卡一区| 欧美日韩在线不卡| 国产在线精品不卡| 夜夜夜精品看看| 久久亚洲春色中文字幕久久久| 成人免费精品视频| 日韩影院免费视频| 久久久美女艺术照精彩视频福利播放| 99久久久免费精品国产一区二区| 午夜影院久久久| 久久久99久久精品欧美| 欧美性猛交xxxx乱大交退制版| 麻豆视频观看网址久久| 亚洲视频在线观看一区| 欧美成人欧美edvon| 色综合激情五月| 韩国在线一区二区| 婷婷久久综合九色国产成人| 国产精品欧美一区二区三区| 欧美片网站yy| 成人h动漫精品一区二区| 肉肉av福利一精品导航| 日韩码欧中文字| 26uuuu精品一区二区| 欧美精品高清视频| av亚洲精华国产精华精| 精品在线一区二区| 午夜精品久久久久影视| 国产精品三级视频| 精品国产一区久久| 欧美一区二区三区视频免费| 91福利国产成人精品照片| 成人午夜在线播放| 韩国精品久久久| 日本少妇一区二区| 亚洲一区二区欧美| 亚洲精品一二三| 中文字幕亚洲在| 国产精品久久久久永久免费观看 | 久久av资源网| 日韩中文字幕91| 亚洲1区2区3区视频| 一区二区三区精密机械公司| 亚洲国产精品v| 国产亚洲欧美一级| 精品国产凹凸成av人导航| 欧美一区三区四区| 91麻豆精品国产自产在线| 在线看国产一区| 日本精品一级二级| 色综合 综合色| 一本大道av伊人久久综合| 99久久777色| 91久久一区二区| 欧美日韩精品一区视频| 欧美日韩免费电影| 制服丝袜在线91| 日韩三级免费观看| 精品久久久久久亚洲综合网| 久久夜色精品国产欧美乱极品| 欧美精品一区二区三区在线播放 | 亚洲第一久久影院| 亚洲第一久久影院| 日韩不卡在线观看日韩不卡视频| 日本亚洲欧美天堂免费| 久久成人综合网| 国产一区二区三区黄视频 | 国产精品大尺度| 亚洲视频 欧洲视频| 亚洲午夜精品一区二区三区他趣| 亚洲综合无码一区二区| 性做久久久久久免费观看| 免费成人在线视频观看| 国产伦精品一区二区三区在线观看 | 国产九色sp调教91| 91亚洲国产成人精品一区二区三| 欧美中文字幕一区二区三区 | 夜夜精品视频一区二区| 青椒成人免费视频| 国产精品一品视频| 在线观看日韩国产| 欧美哺乳videos| 综合久久久久久| 免费人成网站在线观看欧美高清| 国产精品资源网| 在线视频你懂得一区二区三区| 欧美日本在线一区| 国产精品欧美极品| 秋霞午夜av一区二区三区| 国产精品一区二区三区99| 91美女片黄在线观看| 91精品国产色综合久久不卡蜜臀| 国产日产欧美一区二区视频| 亚洲国产视频一区二区| 国产乱码精品一区二区三区忘忧草 | 色天使久久综合网天天| 26uuu国产日韩综合| 亚洲国产精品久久艾草纯爱|