Chapter 11
Tree project


11.3 Trees, Logs, and time Analysis

<1>depth and no. of entries

depth max no. of level

the min no. of nodes to reach depth d for a heap
= 1 + 2 + 4 +....+ 2d-1 + 1
= 2d

since
the total no. of nodes n
>= the min. no. of nodes to reach depth d

==> n >= 2d

==> log2 n >= d

<2> Worst-case Times for tree operations

The worst-case time performance for the
following operations are all O(d) . d : depth of tree

  1. adding an entry in a binary search tree,
    heap or a B-tree.

  2. deleting an entry in a binary search tree,
    heap or a B-tree.

  3. searching for a specific entry in a binary
    search tree or a B-tree.

Note :

  1. the smaller the depth is the more the
    efficiency is. That is why heap and
    B-tree are more efficient compared to other.

  2. O(d) = O(log2 n)

  3. Logarithmic algorithm are algorithm with
    worse-case time O (log2 n)

n ==> log2 n

2n ==> log2 n + 1