actanble

导航

Algorithm Gossip (35) Shaker法

前言

This Series aritcles are all based on the book 《经典算法大全》; 对于该书的所有案例进行一个探究和拓展,并且用python和C++进行实现; 目的是熟悉常用算法过程中的技巧和逻辑拓展。

提出问题

35.Algorithm Gossip:Shaker法 排序法 - - -改良的气泡排序

说明

基于冒泡排序的升级版本;
像这样的基础排序方法, 升级了也是弱渣, 关于这个升级版本可以看本系列的三色旗, 用了这个移动技巧。

分析和解释

代码

拓展和关联

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX 10
#define SWAP(x,y) {int t; t = x; x = y; y = t;}
void shakersort(int[]);
int main(void) {
	int number[MAX] = {0};
	int i;
	srand(time(NULL));
}

后记

** 关于这三个基础排序的升级版我都是一笔带过, 比较简单, 也没什么新意。不了解的可以补补基础教材。 **

参考书籍

  • 《经典算法大全》
  • 维基百科

posted on 2017-04-14 21:41  白于空  阅读(129)  评论(0编辑  收藏  举报