文件名称:search
介绍说明--下载内容均来自于网络,请自行研究使用
以深度为k的满二叉树(n=2k-1)为例,假设表中每个记录的查找概率相等,即 pi=1/n(1≤i≤n),而树的第i层上有2i-1个结点,因此,折半查找的平均查找长度为:
所以,折半查找的平均时间复杂度为O(log2n)。
-To a depth of k over the binary tree (n = 2k-1) as an example, suppose the table to find the probability of each record the same, that is, pi = 1/n (1 ≤ i ≤ n), and the tree layer of the first i There are 2i-1 nodes, therefore, to find half the average length of search as follows: Therefore, to find half the average time complexity is O (log2n).
所以,折半查找的平均时间复杂度为O(log2n)。
-To a depth of k over the binary tree (n = 2k-1) as an example, suppose the table to find the probability of each record the same, that is, pi = 1/n (1 ≤ i ≤ n), and the tree layer of the first i There are 2i-1 nodes, therefore, to find half the average length of search as follows: Therefore, to find half the average time complexity is O (log2n).
(系统自动生成,下载前可以参看下载内容)
下载文件列表
递归折半查找
............\BinSearch2.cpp
............\BinSearch2Main.cpp
............\BinSearch2.cpp
............\BinSearch2Main.cpp