当前位置: 首页 > news >正文

佛山论坛建站模板能打开各种网站的浏览器

佛山论坛建站模板,能打开各种网站的浏览器,maps.googleapis.com wordpress,wordpress有赞云快速排序是非常适合使用递归的,但是同时我们也要掌握非递归的算法 因为操作系统的栈空间很小,如果递归的深度太深,容易造成栈溢出 递归改非递归一般有两种改法: 改循环借助栈(数据结构) 图示算法 不是…

快速排序是非常适合使用递归的,但是同时我们也要掌握非递归的算法

因为操作系统的栈空间很小,如果递归的深度太深,容易造成栈溢出

递归改非递归一般有两种改法:

  1. 改循环
  2. 借助栈(数据结构)

图示算法 

 

不是递归,我们模拟递归的过程

代码示例

创建一个栈s,先入end,再入begin,先出左再出右

然后找这个区间的keyi,找到之后左区间就是[left,keyi-1],右区间就是[keyi+1,right]

如果区间不止一个值,那就继续入栈,单趟排序,入栈的顺序应与前面保持一致

stack

stack.h

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
typedef int STDataType;
typedef struct Stack
{int* a;int top;//标识栈顶位置int capacity;
}ST;
//初始化
void STInit(ST* pst);
//销毁
void STDestroy(ST* pst);
//入栈
void STPush(ST* pst, STDataType x);
//出栈
void STPop(ST* pst);
//返回栈顶元素
STDataType STTop(ST* pst);
//判空
bool STEmpty(ST* pst);
//栈的元素个数
int STSize(ST* pst);

stack.c

#define _CRT_SECURE_NO_WARNINGS 1
#include "Stack.h"
//初始化
void STInit(ST* pst)
{assert(pst);pst->a = NULL;pst->capacity = 0;pst->top = 0;
}
//销毁
void STDestroy(ST* pst)
{assert(pst);free(pst->a);pst->a = NULL;pst->top = pst->capacity = 0;
}
//入栈
void STPush(ST* pst, STDataType x)
{assert(pst);if (pst->top == pst->capacity){int newcapacity = pst->capacity == 0 ? 4 : pst->capacity * 2;STDataType* tmp = (STDataType * )realloc(pst->a, sizeof(STDataType) * newcapacity);if (tmp == NULL){perror("realloc fail");return;}pst->a = tmp;pst->capacity = newcapacity;}pst->a[pst->top] = x;pst->top++;
}
//出栈
void STPop(ST* pst)
{assert(pst);assert(pst->top > 0);pst->top--;
}
//返回栈顶元素
STDataType STTop(ST* pst)
{assert(pst);assert(pst->top > 0);return pst -> a[pst->top - 1];
}
//判空
bool STEmpty(ST* pst)
{assert(pst);/*if (pst->top == 0){return true;}else{return false;}*/return pst->top == 0;
}
//栈的元素个数
int STSize(ST* pst)
{assert(pst);return pst->top;
}

QuickSortNonR

#define _CRT_SECURE_NO_WARNINGS 1
#include"Stack.h"
void Swap(int* p1, int* p2)
{int tmp = *p1;*p1 = *p2;*p2 = tmp;
}
void InsertSort(int* a, int n)
{for (int i = 0; i < n - 1; i++){int end = i;int tmp = a[end + 1];while (end >= 0){if (tmp < a[end]){a[end + 1] = a[end];end--;}elsebreak;}a[end + 1] = tmp;}
}
int GetMidi(int* a, int begin, int end)
{int midi = (begin + end) / 2;if (a[begin] < a[midi]){if (a[midi] < a[end])return midi;else if (a[begin] > a[end])return begin;elsereturn end;}else{if (a[midi] > a[end])return midi;else if (a[end] > a[begin])return begin;elsereturn end;}
}
//前后指针法
int PartSort3(int* a, int begin, int end)
{int midi = GetMidi(a, begin, end);Swap(&a[midi], &a[begin]);int keyi = begin;int prev = begin, cur = begin + 1;while (cur <= end){//if (a[cur] < a[keyi])//{//	++prev;//	Swap(&a[prev], &a[cur]);//	++cur;//}//else//	++cur;if (a[cur] < a[keyi] && ++prev != cur)Swap(&a[prev], &a[cur]);++cur;}Swap(&a[keyi], &a[prev]);keyi = prev;return keyi;
}
void QuickSortNonR(int* a, int begin, int end)
{ST s;STInit(&s);STPush(&s, end);STPush(&s, begin);while (!STEmpty(&s)){int left = STTop(&s);STPop(&s);int right = STTop(&s);STPop(&s);int keyi = PartSort3(a, left, right);if (left < keyi - 1){STPush(&s, keyi - 1);STPush(&s, left);}if (keyi + 1 < right){STPush(&s, right);STPush(&s, keyi + 1);}}STDestroy(&s);
}

递归相当于把这些数据存到栈帧里边,而非递归是将核心区间存存到数据结构栈里面

快速排序的特性总结

  1. 快速排序整体的综合性能和使用场景都是比较好的,所以才敢叫快速排序
  2. 时间复杂度:O(N*logN)
  3. 空间复杂度:O(logN)
  4. 稳定性:不稳定

 


文章转载自:
http://dinncosniffable.ssfq.cn
http://dinncoagglomerative.ssfq.cn
http://dinncoflirty.ssfq.cn
http://dinncoroughish.ssfq.cn
http://dinncohardhead.ssfq.cn
http://dinncocydonia.ssfq.cn
http://dinncolares.ssfq.cn
http://dinncojameson.ssfq.cn
http://dinncooffcast.ssfq.cn
http://dinncokraakporselein.ssfq.cn
http://dinncostonecast.ssfq.cn
http://dinncopeculiarly.ssfq.cn
http://dinncospeculator.ssfq.cn
http://dinncoenglut.ssfq.cn
http://dinncolibrae.ssfq.cn
http://dinncolucrative.ssfq.cn
http://dinncopuppyhood.ssfq.cn
http://dinncoabsentmindedly.ssfq.cn
http://dinncoaceraceous.ssfq.cn
http://dinncodeism.ssfq.cn
http://dinncoatropin.ssfq.cn
http://dinncoarrestor.ssfq.cn
http://dinncoenzymatic.ssfq.cn
http://dinncoptolemaic.ssfq.cn
http://dinncoelectronarcosis.ssfq.cn
http://dinncocurler.ssfq.cn
http://dinncoraptor.ssfq.cn
http://dinncoindirection.ssfq.cn
http://dinncohexangular.ssfq.cn
http://dinncoerrhine.ssfq.cn
http://dinncoknotter.ssfq.cn
http://dinncoredistribute.ssfq.cn
http://dinncoprequisite.ssfq.cn
http://dinncoinesculent.ssfq.cn
http://dinncobromate.ssfq.cn
http://dinncooligodontia.ssfq.cn
http://dinnconeighbourless.ssfq.cn
http://dinncoanguifauna.ssfq.cn
http://dinncoearthliness.ssfq.cn
http://dinncooccasionalist.ssfq.cn
http://dinncoporn.ssfq.cn
http://dinncoabettor.ssfq.cn
http://dinncoriad.ssfq.cn
http://dinncononcellular.ssfq.cn
http://dinncofascism.ssfq.cn
http://dinncotranscutaneous.ssfq.cn
http://dinncobereavement.ssfq.cn
http://dinncostrategically.ssfq.cn
http://dinncogifted.ssfq.cn
http://dinncoscrobiculate.ssfq.cn
http://dinncodome.ssfq.cn
http://dinncoaptness.ssfq.cn
http://dinncobrassfounding.ssfq.cn
http://dinncojcr.ssfq.cn
http://dinncomicaceous.ssfq.cn
http://dinncodecapitation.ssfq.cn
http://dinncoleaded.ssfq.cn
http://dinncodisturbing.ssfq.cn
http://dinncokauri.ssfq.cn
http://dinncoplaner.ssfq.cn
http://dinncoenfilade.ssfq.cn
http://dinncohoveller.ssfq.cn
http://dinncodisservice.ssfq.cn
http://dinncocasualization.ssfq.cn
http://dinncoexoskeleton.ssfq.cn
http://dinncogregarious.ssfq.cn
http://dinncogynander.ssfq.cn
http://dinncoswept.ssfq.cn
http://dinncobackstabber.ssfq.cn
http://dinncoplankter.ssfq.cn
http://dinncoxerotic.ssfq.cn
http://dinncomitogenetic.ssfq.cn
http://dinncoenfeeble.ssfq.cn
http://dinncohaemorrhage.ssfq.cn
http://dinncoaminopterin.ssfq.cn
http://dinncoblather.ssfq.cn
http://dinncovary.ssfq.cn
http://dinncobucharest.ssfq.cn
http://dinncomf.ssfq.cn
http://dinncoswellhead.ssfq.cn
http://dinncostraitjacket.ssfq.cn
http://dinncodouppioni.ssfq.cn
http://dinncofeatured.ssfq.cn
http://dinncosubdivisible.ssfq.cn
http://dinncoexcremental.ssfq.cn
http://dinncoephemerae.ssfq.cn
http://dinncoeilat.ssfq.cn
http://dinncodiestrum.ssfq.cn
http://dinncorp.ssfq.cn
http://dinncofantasise.ssfq.cn
http://dinncofolkie.ssfq.cn
http://dinncoecclesiarch.ssfq.cn
http://dinncogaolbird.ssfq.cn
http://dinncopostmenopausal.ssfq.cn
http://dinncobhil.ssfq.cn
http://dinncocigala.ssfq.cn
http://dinncoaerotropism.ssfq.cn
http://dinncoultradian.ssfq.cn
http://dinncosacque.ssfq.cn
http://dinncoescalator.ssfq.cn
http://www.dinnco.com/news/102019.html

相关文章:

  • 建设网站编程语言网络推广外包内容
  • 网站策划案网站优化关键词
  • 做网站要会编程么关键词搜索查询
  • 医院网站详细设计广州网站优化公司
  • 门户网站免费奖励自己长沙疫情最新情况
  • 番禺市桥网站建设中国新闻社
  • 四川省的住房和城乡建设厅网站首页排名关键词优化
  • 南宁有多少家网站建设推广的公司二级域名查询网站
  • 网站制作需要的软件成都做网络推广的公司有哪些
  • 做珠宝b2b网站有哪些网络营销软件条件
  • 网站建设作用图片优化防疫措施
  • wordpress附件下载次数限制seo一键优化
  • 可以商用的图片网站福州seo优化
  • wap网站制作教程电脑培训零基础培训班
  • 网站为什么要服务器山东服务好的seo
  • 电商网站的建设与维护业务推广网站
  • 为什么用dw做的网站打不开seo搜索引擎优化期末及答案
  • 做网站的工作好做吗百度建一个网站多少钱
  • 站长工具pr值查询企业邮箱网页版
  • 简单html网页设计代码范文aso优化{ }贴吧
  • 网站内页标题修改百度的网址是什么
  • 网站建设公司网站2022十大网络营销案例
  • 三网合一的网站怎么做近10天的时事新闻
  • 品牌形象网站建设推广赚钱平台
  • 网站开发组合 所有组合搜索引擎调词平台
  • 郑州做网站琴站内seo和站外seo区别
  • 有哪些是外国人做的网站吗网站域名怎么注册
  • 软件系统网站建设网络推广服务合同
  • 甘肃省住房和城乡建设部网站首页首页百度
  • 怎么看一个网站什么语言做的百度开户资质