C语言编程学习课件 (31).pdf

上传人:刘静 文档编号:57975695 上传时间:2022-11-06 格式:PDF 页数:8 大小:1.49MB
返回 下载 相关 举报
C语言编程学习课件 (31).pdf_第1页
第1页 / 共8页
C语言编程学习课件 (31).pdf_第2页
第2页 / 共8页
点击查看更多>>
资源描述

《C语言编程学习课件 (31).pdf》由会员分享,可在线阅读,更多相关《C语言编程学习课件 (31).pdf(8页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、Programming In CProgramming In C Sequential Search The sequential search,also known as linear search.Start with the first number of the data list and search the number one by one.5 21 23 10 7 15 18 2 6 20 For example,the number we entered from the keyboard is 7.Then the searching process is as shown

2、 above.Assuming there is a data list:7 not equal 7 equal In this way,we find the number 7 in the data list,and we can determine that it is the third element.Sequential Search 5 21 23 10 7 15 18 2 6 20 For example,the number we entered from the keyboard is 25.Then the searching process is as shown be

3、low.However,what if the number we entered from the keyboard is not in the data list?25 not equal In this way,no element equal to 25 has been found in the data list.Code Running result 7 The position of 7 is:3 Running result 25 The number is not found!Binary Search Here I will introduce to you a more

4、 efficient searching method:binary search.A necessary premise for binary search is that the data list should be an ordered sequence.That is,the data list is arranged in ascending or descending order.For example,there is such a sequence data.Suppose we want to search 16 in the sequence.We first compa

5、re 16 with the number 13 in the middle of the sequence.Because 16 is bigger than 13,it will never appear in a position smaller than 13.That means 16 will be in the right half of the sequence.16 not equal should go this way Binary Search Therefore,we exclude the first half of the sequence and do a binary search on the second half of the sequence.Because 16 is in the middle of the second half,compare the values of them,then we find it.So we find it.16 not equal 16 equal Code Running result 16 The position of 16 is:7 Programming In CProgramming In C

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 大学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com