- 6
- 0
- 约1.89千字
- 约 7页
- 2016-12-29 发布于北京
- 举报
* 西南财经大学天府学院 LOGO 顺序查找(Sequential Search) Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 顺序查找(Sequential Search) 基本思想:从顺序表的一端向另一端逐个将表中的数据与给定的目标值进行比较,若相等,则查找成功,并给出该目标值在表中的位置;若整个表检测完仍未找到与目标值相等的数据,则查找失败,给出查找失败信息。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. a i=9 a i=0 60 i=11 Target = 80 Target = 60 i=11 80 顺序查找——哨兵查找( Sentinel search ) 基本思想:设置“监视哨”。哨兵就是待查值,将它放在查找方向的尽头处。 i=10 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 哨兵查找算法 (Sequential Search algorithm ) 算法需要完成两件事: 是否找到目标数据:Target 如果找到,在顺序表中的位置在哪里,即返回the index。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. algorithm seqsearch(val list array val last index val target keytype ref locn index) list [0] = target // 设置“监视哨” looker=last loop (target not equal list [looker]) looker = looker - 1 end loop locn = looker if (looker 0) found = true locn = looker else found = false locn = 0 end if return found end sentinel search 哨兵查找算法(Sequential Search algorithm ) Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 哨兵查找算法(C语言实现) #include ”stdio.h” main() { } int a[12]={-1,21,37,88,19,92,5,64,56,80,75,13}; int target,i; a[0]=target; printf(“Enter your search target(an integer):”); scanf(“%d”,target); printf(“The target has been found,it’s intex is:%d\n”,i); else printf(“The target isn’t found.\n”); i=11; while(a[i]!=target) { } i=i-1; if(i0) Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd.
您可能关注的文档
- 《项目开发流程ppt.ppt
- 《项目总结工作汇报PPT模板ppt.ppt
- 《项目性销售基础.ppt
- 《项目成本管控流程培训1224.ppt
- 《项目成本管理.ppt
- 《项目技术管理课件1.ppt
- 《项目成熟度第一章2.ppt
- 《项目投融资案例分析2.ppt
- 《项目投资.pptx
- 《项目推广流程.ppt
- 2026年浙江农林大学单招职业倾向性考试题库及参考答案详解.docx
- 2026年浙江农林大学单招职业倾向性考试题库及参考答案详解1套.docx
- 2026年浙江农林大学单招职业倾向性考试题库及参考答案详解一套.docx
- 2026年浙江农林大学单招职业倾向性考试题库附答案详解.docx
- 2026年浙江农林大学单招职业倾向性测试题库带答案详解.docx
- 2026年浙江农林大学单招职业倾向性测试题库含答案详解.docx
- 2026年浙江农林大学单招职业倾向性考试题库带答案详解.docx
- 2026年浙江农林大学单招职业倾向性测试题库及答案详解1套.docx
- 2026年互联网医疗平台运营案例研究分析报告.docx
- 2026年浙江农林大学单招职业倾向性测试题库及参考答案详解一套.docx
原创力文档

文档评论(0)