0% found this document useful (0 votes)
321 views1 page

Cs 301

The document discusses properties of complete binary trees and their nodes. It notes that a complete binary tree of depth d will have 2d+1 - 1 total nodes, with 2d leaf nodes and 2d - 1 non-leaf nodes. It also states that the maximum number of executions of a while loop in a binary tree of depth d will be equal to d.

Uploaded by

foggybluue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
321 views1 page

Cs 301

The document discusses properties of complete binary trees and their nodes. It notes that a complete binary tree of depth d will have 2d+1 - 1 total nodes, with 2d leaf nodes and 2d - 1 non-leaf nodes. It also states that the maximum number of executions of a while loop in a binary tree of depth d will be equal to d.

Uploaded by

foggybluue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

The total number of nodes (leaf and non-leaf nodes) of a complete binary tree of depth d is

equal to 2d+1 – 1.
In a complete binary tree there are 2d leaf nodes and 2d – 1 non-leaf nodes.
𝑇𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑛𝑜𝑑𝑒𝑠, 𝑛 = 2𝑑+1 − 1
2𝑑+1 − 1 = 𝑛
𝑑 = log 2 (𝑛 + 1) − 1
In a given binary tree of depth d, the maximum number of executions of the while loop will be
equal to d.
Convert infix to postfix using stack Lecture 07
Convert expression tree to infix using in-order recursive Lecture 25
traversal
Convert postfix to expression tree using stack Lecture 25

It is not necessary that expression tree is always binary tree.


A binary tree with N internal nodes has N+1 external nodes.
A binary tree with N internal nodes has 2N links: N-1 links to internal nodes and N+1 links to
external nodes.
The new definition of complete binary tree has 2h to 2h+1 – 1 nodes.
Each call to insert will either take unit time (leaf node) or log2 (N) (if new key percolates all the
way up to the root). The worst time for building a heap of N keys could be N log2 (N).
If unions are done by weight (size), the depth of any element is never greater than log2 (N).

You might also like