DS Chapter VII learning summary

Chapter VII Summary

To list some basic concepts:

① Keywords: the value of a data item of data elements (records), it can be represented by a data element.

 

② dynamic lookup table / static lookup table: If the modification operations (insert or delete) in the search process, the corresponding table is dynamic lookup table, otherwise static lookup table.

 

③ average length: to determine a recording location in the lookup table, the need and value of a given number of expected value comparing keyword search algorithm is called upon to find the average length of success. Following formula: ASL = ΣPiCi (i = 1,2,3, ..., n), may simply be a desired mathematical so understood. Where: Pi is the probability of finding the number of tables in the i-th data elements, Ci is found when the i-th elements have compared the data.

 

The following figure shows the chapter Mind Mapping

1. sequential search

   Starting from one end of the table, scanning the table sequentially, to sequentially scan the node key and a given value (assumed to be a) comparing, if the current node is equal to a keyword, the search is successful; if after the end of the scan, yet to find keyword equal to a node, then the lookup fails.

      Sequential search method is the most common one, when we started to learn almost always find this method, which is to start from scratch, one by one comparison, so this is one of the least efficient method.

      Suitable for sequential storage structure and the storage structure chain linear form.

   The average length lookup lookup is successful: ASL = 1 / n (1 + 2 + 3 + ... + n) = (n + 1) / 2;

 2. binary search

      Search process from the middle of the array elements, if the intermediate element the element is just looking for, the search process ends; if a particular element is greater than or less than the intermediate element in the array is greater or less than half that of the intermediate element lookup, and Like start start comparing the middle element. If at some stage array is empty, it represents not found. This search algorithm so that each comparison search reduced by half.

    

    Calculation of binary mid formula

    mid = (low+high)/2;
        if(a[mid]==value)
            return mid;
        if(a[mid]>value)
            high = mid-1;
        if(a[mid]<value)
            low = mid+1;

3.  分块查找

   二分查找表使分块有序的线性表和索引表(抽取各块中的最大关键字及其起始位置构成索引表)组成,由于表是分块有序的,所以索引表是一个递增有序表,因此采用顺序或二分查找索引表,以               确定待查结点在哪                 一 块,由于块内无序,只能用顺序查找。 

4.  树表查找 

   

    二叉排序树(Binary Sort Tree),又称为二叉查找树。它或者是一棵空树,或者是具有下列性质的二叉树。
        若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值;
        若它的右子树不空 ,则右子树上所有结点的值均大于它的根结点的值;
        它的左、右子树也分别为二叉排序树。

 

 

    平衡二叉树(AVL树)

          平衡二叉树,是一种二叉排序树,其中每一个节点的左子树和右子树的高度差至多等于1。

          从平衡二叉的英文名字(AVL树),你也可以体会到,它是一种高度平衡的二叉排序树。

          高度平衡意思是说,要么它是一棵空树,要么它的左子树和右子树都是平衡二叉树,且左子树和右子树的深度之差的绝对值不超过1。

  

 

 

  B-树

    B树可以看作是对查找树的一种扩展,即他允许每个节点有M-1个子节点。

    •   根节点至少有两个子节点

    •   每个节点有M-1个key,并且以升序排列

    •   位于M-1和M key的子节点的值位于M-1 和M key对应的Value之间

    • 其它节点至少有M/2个子节点

      B+树

    • B+树是对B树的一种变形树,它与B树的差异在于:

    • 有k个子结点的结点必然有k个关键码;
    • 非叶结点仅具有索引作用,跟记录有关的信息均存放在叶结点中。
    • 树的所有叶结点构成一个有序链表,可以按照关键码排序的次序遍历全部记录。
 

 

5.  散列表

   (1)基本概念:
    散列函数和散列地址:在记录的存储位置p和其关键字key之间建立一个确定的对应关系H,使p=H(key),称这个对应关系H为散列函数,p为散列地址。
    散列表:一个有限连续的地址空间,用以存储按散列函数计算得到相应散列地址的数据记录。
    冲突和同义词:对不同的关键字可能得到同一散列地址,这种现象成为冲突。具有相同函数值的关键字对该散列函数来说称作同义词,key1和key2互称为同义词。

   (2)散列函数的构造方法:

    数字分析法;平方取中法;折叠法;除留余数法 (假设散列表表长为m,选择一个不大于m的数p,用p去除关键字,除后所得余数为散列地址)

   (3)处理冲突的办法

    开放地址法:线性探测法;二次探测法;伪随机探测法

               链地址法

总结

上一次的目标基本达成,还顺带学习了一下map的用法,

下一阶段的目标:备考准备,好好复习。

 

Guess you like

Origin www.cnblogs.com/hxyawsl/p/10963574.html