查找技术的前世今生分析.ppt

  1. 1、本文档共34页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
查找技术的前世今生分析

B- 树 A B-tree of order m is an m-way tree (i.e., a tree where each node may have up to m children) in which: 1. the number of keys in each non-leaf node is one less than the number of its children and these keys partition the keys in the children in the fashion of a search tree(见缝插针) 2. all leaves are on the same level(叶子同级) 3. all non-leaf nodes except the root have at least ?m / 2? children(最小子树原则) 4. the root is either a leaf node, or it has from two to m children(根必须=2棵子树) 5. a leaf node contains no more than m – 1 keys(叶子的 key= m-1) The number m should always be odd(最大的m棵子树这个数字始终是奇数) 图示 动画:/java/bt/view.php 数学分析:最坏情况下高度分析 B+ Tree Similar to B- trees, with a few slight(与B- 树相同,有几点不同之处) differences  All data is stored at the leaf nodes (leaf pages); all other nodes (index pages) only store keys (所有的具体数据存储在叶子节点的指针,其他节点充当路由)  Leaf pages are linked to each other (为了for循环遍历方便,叶子的数据节点一个接一个被指针链接起来)  Keys may be duplicated; every key to the right of a particular key is = to that key 动画/lms/nav/activity.jsp?sid=__sharedcid=usu@millslid=53 Tankertanker Design 查找技术的前世今生 送大家两句格言: 一个人如果把从别人那里学来的东西算作自己的发现,这也很接近于虚骄。 --黑格尔 一个永远也不欣赏别人工作的人,也就是一个永远也不被别人欣赏的人。 --汪国真 讲课原则 1.原理上把握,贯彻数学分析   “历史上所有伟大的思想家都在寻找一个真理,一个他人无法辩驳的真理,就像2+2=4,为了寻找这样的真理,要实现这样一个既定目标,还有什么比这个永恒而不变且不受人类情感所左右的方式更合适呢?世上除数学之外,根本不存在所谓真理,可以解答人类全部疑惑的无懈可击的绝对真理—让人无法反驳的论据”。   所以对于“那些数学上不可言说的,我们必须保持缄默”。 --《逻辑哲学论》第七节 作者:维特根斯坦 2.主流查找技术,讲基础 “墙高基下,虽得必失” --南朝宋史学家 范晔 算法分析的性能指标 1.时间复杂度 比如:遍历一个数组的时间复杂度是O(n) 2.空间复杂度 内存耗费的数量级 查找 查找技术与存储(查和存) 查找技术与排序 都有着深刻的关系 讲解内容: 顺序查找法 折半查找法 hash表法 排序二叉树 平衡二叉树 堆(heap) B- 树 B+ 树 1.顺序查找法 --任何程序员都会 伪代码: function linear_search(array, key){ for(int i = 0; i array.length; i++){ if(array[i] == key){ return i; } } return -1; } 科学性能指标: 平均查找长度ASL(Average Search Length) (n+1)/2 折半查找法(binary search) 1.需要先排序 快速排序(可能退化为冒泡排序法),堆排序等,时间复杂度为n*log(n) 2.进行折半查找 int binary_search(int array[], int low, int high, int target) { while(low = high) {

文档评论(0)

441113422 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档