十大排序算法(思路+代码)
以数组为例,介绍十大排序算法的思路与实现
ㄨㄛˇㄞˋㄋㄧˇ
别看了,是大汉
展开
-
十大排序算法
本文列举了十大排序算法,并给出了实现方法原创 2021-12-27 11:50:51 · 349 阅读 · 0 评论 -
十大排序算法之——基数排序
代码如下:#include <iostream>#include <cmath>using namespace std;#define INF -100000#define MAXSIZE 30typedef int ElemType;typedef struct Node{ ElemType e; struct Node *next;} * List;typedef struct BNode{ List l[10];} * Bucke原创 2021-12-27 11:47:20 · 266 阅读 · 0 评论 -
十大排序算法之——快速排序
代码如下#include <iostream>using namespace std;typedef int ElemType;void Qsort(ElemType A[], int low, int high, int N){ if (low >= high) return; int l = low, r = high + 1; int self = A[low]; //暂时“隐藏”基准 while (l < r) { while (A[++l] &原创 2021-12-27 11:40:37 · 145 阅读 · 0 评论 -
十大排序算法之——归并排序
归并排序案例:归并排序代码:原创 2021-12-27 11:35:48 · 135 阅读 · 0 评论 -
十大排序算法之——选择排序
选择排序代码#include <iostream>typedef int ElementType;using namespace std;long *arr;int N;void Selection_Sort(){ for(int j=N;j>0;j--) { int max_idx=0; for(int i=0;i<j;i++) { if(arr[max原创 2021-12-27 11:29:33 · 195 阅读 · 0 评论 -
十大排序算法之——插入排序
插入排序代码如下原创 2021-12-27 11:24:00 · 371 阅读 · 0 评论 -
快慢指针实现归并排序
给俩非递减数组,长度m,n,用o(m+n)实现将两个数组归并到第一个数组且使用顺序表。#include<stdio.h>#include <stdlib.h>#define N 50void swap(int * a,int *b){ int t=*a; *a=*b; *b=t;}bool combine(int a[],int b[],int m,int n){ if(n==0) { return 1;原创 2021-11-13 23:12:49 · 931 阅读 · 1 评论 -
排序算法之——堆排序
选择排序选择排序堆排序选择排序代码#include <iostream>#include <cstdio>#include <vector>#include <queue>typedef int ElementType;using namespace std;long *arr;int N;void Selection_Sort(){ for(int j=N;j>0;j--) { int max_i原创 2021-09-11 06:24:52 · 57 阅读 · 0 评论 -
十大排序算法之——希尔排序(插入排序进阶)
代码如下:原创 2021-09-10 10:35:02 · 163 阅读 · 0 评论 -
十大排序算法之——冒泡排序
冒泡排序 方法 步骤 例子 代码原创 2021-09-08 09:53:03 · 95 阅读 · 0 评论