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

最好的php网站开发工具短视频营销论文

最好的php网站开发工具,短视频营销论文,知乎 做照片好的网站,腾讯cdn加速优化wordpress快速排序的非递归 我们写快速排序的时候#xff0c;通常用的递归的方法实现快速排序#xff0c;那么有没有非递归的方法实现快速排序呢#xff1f;肯定是有的。思想还是一样的#xff0c;不过非递归是看似是非递归其实还是递归。 思路解释 快速排序的非递归使用的是栈这…快速排序的非递归 我们写快速排序的时候通常用的递归的方法实现快速排序那么有没有非递归的方法实现快速排序呢肯定是有的。思想还是一样的不过非递归是看似是非递归其实还是递归。 思路解释 快速排序的非递归使用的是栈这个数据结构。我们知道栈是后入先出和先入后出的所以我们可以通过栈的方式模拟递归然后实现快速排序的非递归。 如图所示创建一个栈。然后首先先将数组的起始和末尾的下标存进栈中然后让leftbeginrightend并pop出去。然后进行一次快排找到keyi。此时如果keyi两边的区间绿色的存在就把keyi也存进栈。然后进行一次快排当区间为空或者区间值有序就把值从栈中pop出来如果不是就继续push进去直到栈为空。最后别忘了把栈给销毁。 代码 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[begin] a[end])return begin;elsereturn end;} } int PSort(int* a, int begin, int end) {int midi GetMidi(a, begin, end);Swap(a[midi], a[begin]);int key begin;int prev begin;int cur prev 1;while (cur end){if (a[cur] a[key] prev ! cur)Swap(a[cur], a[prev]);cur;}Swap(a[key], a[prev]);key prev;return key; } 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 PSort(a, left, right);// [left, keyi-1] keyi [keyi1, 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); }下面是栈的头文件和.c文件 #include stdio.h #includeassert.h #includestdlib.h #includestdbool.h typedef struct Stack {int* a;int top; // 标识栈顶位置的int capacity; }ST; void STInit(ST* pst);//初始化栈 void STDestroy(ST* pst);//栈的销毁 void STPush(ST* pst, int x);//栈顶插入 void STPop(ST* pst);//栈顶删除 int STTop(ST* pst);//获取栈顶元素 bool STEmpty(ST* pst);//检查栈是否为空 int STSize(ST* pst);//获取栈中元素的个数 #include stack.h void STInit(ST* pst) {/*ST* tmp (ST*)malloc(sizeof(ST));if (tmp NULL){perror(malloc);return;}*/pst-a NULL;pst-top -1;pst-capacity 0; } void STPush(ST* pst, int x) {assert(pst);if (pst-top pst-capacity - 1){int newcapacite pst-capacity 0 ? 4 : pst-capacity * 2;int* tmp (int*)realloc(pst-a, newcapacite * sizeof(int));if (tmp NULL){perror(realloc);return;}pst-a tmp;pst-capacity newcapacite;}pst-a[pst-top 1] x;pst-top; } void STPop(ST* pst) {assert(pst);pst-top--; } int STTop(ST* pst) {assert(pst);if (pst-top -1){printf(此栈为空);return 1;}return pst-a[pst-top]; } bool STEmpty(ST* pst) {assert(pst);return pst-top -1; } int STSize(ST* pst) {assert(pst);return pst-top; } void STDestroy(ST* pst) {assert(pst);free(pst-a);pst-a NULL;pst-capacity 0;pst-top -1;}
http://www.hkea.cn/news/14398910/

相关文章:

  • 建设公司网站编号wordpress主动推送所有网址插件
  • 设计师常备设计网站大全网站建设分析报告
  • 微信h5制作网站开发服务器搭建网站
  • 网站title如何写综合门户网站源码
  • 杭州市建设工程检测协会网站什么网站做网页好
  • 怎样下载模板网站最好旅游网站建设
  • 做一钓鱼网站wordpress ios源码
  • 怎么根据别人的网站做自己的网站网站建设实训存在的问题
  • 旅游网站建设需求说明书湖北省城乡建设厅证书查询
  • 专门做外贸的的网站有哪些化妆品网站开发的外文翻译
  • 旅游网站如何建设建设银行e路通网网站
  • 网站建设实践鉴定新闻摘抄2023年
  • 在线网站建设培训班亦庄公司做网站
  • 个人网站做百度云电影链接犯法吗建设厅的证全国通用吗
  • 江苏金安建设公司网站如何创建网站挣钱
  • 网站建设业务员转换大白银市建设局网站首页
  • 做原油看哪个网站社交电商怎么做赚钱
  • 四川建设行政主管部门官方网站代理网页是干什么的
  • 可以搜索任何网站的浏览器织梦移动端网站模板下载
  • 做网站维护有没有前途贵阳做网站 优帮云
  • 徐州建设银行网上银行个人网站哪些网站可以做gif
  • 化肥网站模板微信小程序开发介绍
  • 商丘河南网站建设信宜做网站
  • 涪陵做网站手机网站怎么设计
  • 不是网站可以用云主机吗重庆新闻app
  • 手机网站前端开发布局技巧古德设计官网
  • 明快网站设计什么是跨境电商主要做什么
  • 网站建设视频图片怎么模仿别人做网站
  • 购物网站建设的可行性asp.net网站访问统计
  • app免费制作网站模板wordpress这么用