• Trees


    For large amounts of input, the linear access time of linked lists is prohibitive. In this chapter, we look at a simple data structure for which the running time of most operations is O(logN) on average.
    In this chapter,  we will :
    • see how trees are used to implement the file system of several popular operatiing systems.
    • see how trees can be used to evaluate arithmetic expressions.
    • Show how to use trees to support searching operations in O(logN) average time, and how to refine these ideas to obtain O(lognN) worst-case bounds we will also see how to implement these operations when the data are stored on a disk.
     
    Preliminaries
         
         A tree can be defined in several ways. one natural way to define a tree is recursively. A tree is a collection of nodes. The collection can be empty; otherwise, a tree consists of a disinguished node r , called the root, and zero or more nonempty (sub)trees T1,T2,..,Tk, each of whose roots are connected by a directed edge from r.
     
         The root of each subtree is said to be a child of r, and r is the parent of each subtree root.
     
         From the recursive defintion, we find that a tree is a collection of N nodes, one of which is the root, and N-1 edges. That there are N-1 edges follows from the fact that each edge connects some node to its parent , and every node except the root has one parent.
     
     
         Leaves: the node in a tree has no child
         Sibling : the nodes have the same parent.
         Path : define as a sequence of nodes n1,n2,...,nk such that ni is the parent of ni+1 for 1<= i < k.
         The Length of Path : is the number of edges on the path, namely k-1.
     
         Depth : for any node ni, the depth of ni is the length of the unique path from  the root to ni. Thus, the root is at depth 0.
         Height : The height of ni is the length of the longest path from ni to a leaf.
     
     
     
      not end ....
     
     
     
  • 相关阅读:
    找工作就上智联,效果真快,然而让我去的公司都是泡我呢
    只能面深度学习岗和算法岗,其他都不会
    2维矩阵前缀和技巧题目
    计算机基础背诵
    集合函数AVG,SUM,MAX,MIN
    集合函数COUNT
    修改删除数据记录
    多表查询
    查询数据表中的记录
    SQL基本语句(3) LOAD DATA INFILE
  • 原文地址:https://www.cnblogs.com/loveyakamoz/p/2770036.html
Copyright © 2020-2023  润新知