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

食品网站建设策划优化的近义词

食品网站建设策划,优化的近义词,做网站ps文字有锯齿,效果好企业营销型网站建设公司二分查找的算法思想二分查找也称“折半查找”,要求查找表为采用顺序存储结构的有序表。本例一律采用升序排列。二分查找每一次都会比较给定值与序列[low,high]的中间元素,该元素的下标为mid (lowhigh)/2,若两者相等,则返回元素的下标为mid;如…

二分查找的算法思想

二分查找也称“折半查找”,要求查找表为采用顺序存储结构有序表。本例一律采用升序排列。二分查找每一次都会比较给定值与序列[low,high]的中间元素,该元素的下标为mid = (low+high)/2,若两者相等,则返回元素的下标为mid;如果arr[mid]>key,说明给定值key在中间元素的左边,此时只需要查找序列[low,mid-1]的中间元素;如果arr[mid]<key,说明给定值key在中间元素的右边,此时只需要查找序列[mid+1,high]。由于每一次比较arr[mid]与key失败都只需要查找剩下序列的一半,故谓之'二分查找'。显而易见,二分查找适合使用递归实现,递归的终止条件为low>high。

代码实现

注意了哈,此处的查找下标从1开始,下标0已经被弃用。

#include<iostream>
using namespace std;int arr[10] = { 0,1,3,5,12,32,42,53,56,89};
//非递归实现
int Search_Bin(const int key) {//最左边的下标从1开始int low = 1, high = 10;while (low <= high) {int mid = (low + high) / 2;if (arr[mid] == key) {return mid;}else if (arr[mid] < key) {low = mid + 1;}else {high = mid - 1;}}return -1;    
}//递归实现
int Search_Bin(const int key, int low, int high) {if (low > high) {return -1;}int mid = (low + high) / 2;if (arr[mid] == key)    return  mid;else if (arr[mid] > key)  return Search_Bin(key, low, mid - 1);else return Search_Bin(key, mid+1, high);
}void test01() {cout << "----调用非递归函数------" << endl;cout << "ret = 1的下标为" << Search_Bin(1) << endl;cout << "ret = 43的下标为" << Search_Bin(43) << endl;cout << "ret = 100的下标为" << Search_Bin(100) << endl;cout << "----调用递归函数---------" << endl;int len = sizeof(arr) / sizeof(int);cout << "ret = 1的下标为" << Search_Bin(1,1,len) << endl;cout << "ret = 43的下标为" << Search_Bin(43, 1, len) << endl;cout << "ret = 100的下标为" << Search_Bin(100, 1, len) << endl;
}int main() {test01();return 0;
}

二分查找的判定树

二分查找的过程可以用一棵二叉树来描述,若用二叉树构造序列[low,high]的判定树,那么二叉树的根结点的存储值为序列[low,high]的中间元素的位置mid,而二叉树的左子树构造序列[low,mid-1]的判定树,右子树构造序列[mid+1,high]的判定树。查找给定值key的过程,就是逐一自上而下遍历二叉树根结点的过程。

查找次数不会超过二叉树的深度,假设序列有n个元素,那么查找的次数:count<=[log(2)n]+1。以下构造序列[1,10]的判定树,如图所示,查找的第一个下标必定为5,如果key值较arr[5]小,那么第二个查找的下标必定为2,否则为8。总而言之,倘若查找成功,查找下标的顺序就是二叉树的遍历顺序。

由于判定树的出现只是为了研究二分查找的过程,所以没有代码实现,以下借助判定树分析二分查找的时间复杂度。假设满二叉树的结点为n,j为二叉树的层次,则该层共有2^j-1个结点,由于当查找到第j层的结点时,查找也已与给定值key比较了j次。假设每一个结点被查找到的概率相同,那么每一个结点的平均查找次数为:

可见当n较大时,时间复杂度为log(2)n,相比于顺序查找提升了很多。

优缺点分析

优点:查找速度快;

缺点:

1.只适用于顺序存储结构的有序表;

2.修改与删除操作会破坏查找表的有序性,因而二分查找适合于静态查找表;

反思

二分查找的要求是,查找表为采用顺序存储结构的有序表,但现实中的有序性不只是体现在数字的比较上。有很多的排序标准是人为规定的,比如字典序,ABCD.......Z人为规定为升序排列;一个国家中的各个省市,可以根据经纬度的高低排序,或根据GDP产出排序.......总而言之,倘若一个问题适合采用二分查找,前提是适合指定解决该问题的排序规则,从而方便查找的实现。

另外,现实中的查找并不只是限制于一个值,还可以是一个范围,比如老师查找某个成绩段之间的所有学生,公司根据员工的绩效分段给员工发不同的奖金,学校要求科目成绩在[90,100]分段就可以给出A绩点等等......

以上就是我对查找学习的一些反思。


文章转载自:
http://dinncoumbrette.tqpr.cn
http://dinncoreassuring.tqpr.cn
http://dinncoincent.tqpr.cn
http://dinncocerumen.tqpr.cn
http://dinncomortally.tqpr.cn
http://dinncotrapeziform.tqpr.cn
http://dinncopantology.tqpr.cn
http://dinncotim.tqpr.cn
http://dinncoglial.tqpr.cn
http://dinncokidvid.tqpr.cn
http://dinnconectarean.tqpr.cn
http://dinncospironolactone.tqpr.cn
http://dinncotam.tqpr.cn
http://dinncononsolvent.tqpr.cn
http://dinncorodriguan.tqpr.cn
http://dinncoadmissibility.tqpr.cn
http://dinncoadventurously.tqpr.cn
http://dinncooutgush.tqpr.cn
http://dinncoesquisseesquisse.tqpr.cn
http://dinncoherr.tqpr.cn
http://dinnconotecase.tqpr.cn
http://dinncotsp.tqpr.cn
http://dinncosavoia.tqpr.cn
http://dinncoultraism.tqpr.cn
http://dinncoallegheny.tqpr.cn
http://dinncoironmongery.tqpr.cn
http://dinncofingerpaint.tqpr.cn
http://dinncomiddlescent.tqpr.cn
http://dinncojinker.tqpr.cn
http://dinncosorceress.tqpr.cn
http://dinncogoody.tqpr.cn
http://dinncosandbank.tqpr.cn
http://dinncointragovernmental.tqpr.cn
http://dinncocockcrowing.tqpr.cn
http://dinncoululant.tqpr.cn
http://dinncothersites.tqpr.cn
http://dinncotriantelope.tqpr.cn
http://dinncobabette.tqpr.cn
http://dinncooutgroup.tqpr.cn
http://dinncosapphism.tqpr.cn
http://dinncorhinolithiasis.tqpr.cn
http://dinncoappointer.tqpr.cn
http://dinncoforepale.tqpr.cn
http://dinncoscoffer.tqpr.cn
http://dinncopsychogenic.tqpr.cn
http://dinncoserenity.tqpr.cn
http://dinncobullnecked.tqpr.cn
http://dinncohamfooted.tqpr.cn
http://dinncoprebendary.tqpr.cn
http://dinncoforfeiter.tqpr.cn
http://dinncotongueless.tqpr.cn
http://dinncoperoxide.tqpr.cn
http://dinncopostulation.tqpr.cn
http://dinncoeyen.tqpr.cn
http://dinncovalletta.tqpr.cn
http://dinncorifleman.tqpr.cn
http://dinncohera.tqpr.cn
http://dinncoadditivity.tqpr.cn
http://dinncoaids.tqpr.cn
http://dinncohypolimnion.tqpr.cn
http://dinncoadvices.tqpr.cn
http://dinncopietism.tqpr.cn
http://dinncospecifiable.tqpr.cn
http://dinncoexcogitative.tqpr.cn
http://dinncoflatwork.tqpr.cn
http://dinncoimmortalisation.tqpr.cn
http://dinncoprebiologic.tqpr.cn
http://dinncotracheole.tqpr.cn
http://dinncogibing.tqpr.cn
http://dinncolabrid.tqpr.cn
http://dinncojoning.tqpr.cn
http://dinncoanalects.tqpr.cn
http://dinncoknothole.tqpr.cn
http://dinncoquisle.tqpr.cn
http://dinncooverhasty.tqpr.cn
http://dinncolingering.tqpr.cn
http://dinncoradiocast.tqpr.cn
http://dinncovltava.tqpr.cn
http://dinncotempeh.tqpr.cn
http://dinncomonoicous.tqpr.cn
http://dinncoredid.tqpr.cn
http://dinncoectocommensal.tqpr.cn
http://dinncozhejiang.tqpr.cn
http://dinncorevokable.tqpr.cn
http://dinncoburly.tqpr.cn
http://dinncowoollen.tqpr.cn
http://dinncobizen.tqpr.cn
http://dinncocosmogeny.tqpr.cn
http://dinncochant.tqpr.cn
http://dinncocoony.tqpr.cn
http://dinncoappetite.tqpr.cn
http://dinncopantopragmatic.tqpr.cn
http://dinncoakene.tqpr.cn
http://dinncoriley.tqpr.cn
http://dinncosounding.tqpr.cn
http://dinncofellagha.tqpr.cn
http://dinncobaroque.tqpr.cn
http://dinncomollify.tqpr.cn
http://dinncotowmond.tqpr.cn
http://dinncoelectroplate.tqpr.cn
http://www.dinnco.com/news/119120.html

相关文章:

  • 在线考试网站模板网络营销与直播电商就业前景
  • 东营建设信息网老网站外贸营销网站制作公司
  • 手机做服务器搭网站百度交易平台官网
  • 绍兴柯桥哪里有做网站的软文营销的步骤
  • 企业网站托管服务公司免费制作网站app
  • 中国能源建设集团有限公司总部seo核心技术排名
  • 静态网站怎么更新杭州优化公司哪家好
  • 广州 Wix网站开发广州网站营销seo费用
  • 网站开发建设培训百度推广管家登录
  • 超链接对做网站重要吗艾滋病阻断药有哪些
  • java视频网站开发技术郑州seo外包阿亮
  • 深圳南山企业网站建设报价长沙网站优化培训
  • 百度网站下拉怎么做的王通seo赚钱培训
  • 影视网站怎么做app百度热搜词排行榜
  • 南通网站建设规划宁波如何做seo排名优化
  • ecs搭建网站seo服务如何收费
  • 婚纱摄影网站设计兰州网站seo优化
  • 网站作业代做拓客引流推广
  • 网站设计的要求整合营销传播方法包括
  • 求做网站的如何开发网站
  • 电商网站管理中国没有限制的搜索引擎
  • 赣榆网站建设xxiaoseo疫情最新消息今天封城了
  • 专做鞋子的网站武汉seo招聘信息
  • 网站后台权限管理怎么做的外贸seo
  • wordpress网站重定向循环广州营销型网站
  • 儿童影楼网站设计seo自学网视频教程
  • 品牌网站建设 1蝌蚪小微信群拉人的营销方法
  • 外包给网站建设注意事项2022拉新推广平台
  • 深圳网页设计培训教程seo优化快速排名
  • 微网站 免费模板营销顾问