From a61627cf9ca6246cbc887d86409d56a532ff430c Mon Sep 17 00:00:00 2001 From: isha2812 <34786144+isha2812@users.noreply.github.com> Date: Wed, 6 Mar 2019 03:01:41 +0530 Subject: [PATCH] added about perfect binary tree in index.md (#26201) --- guide/english/algorithms/binary-search-trees/index.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/guide/english/algorithms/binary-search-trees/index.md b/guide/english/algorithms/binary-search-trees/index.md index faba67e777..68fbeed12f 100644 --- a/guide/english/algorithms/binary-search-trees/index.md +++ b/guide/english/algorithms/binary-search-trees/index.md @@ -350,8 +350,15 @@ Complete Binary Tree: A Binary Tree is complete Binary Tree if all levels are co / \ / 8 7 9 -### Augumenting a BST +Perfect Binary Tree A Binary tree is Perfect Binary Tree in which all internal nodes have two children and all leaves are at the same level. + 18 + / \ + 15 30 + / \ / \ + 40 50 100 40 + +### Augumenting a BST Sometimes we need to store some additional information with the traditional data structures to make our tasks easier. For example, consider a scenario where you are supposed to find the ith smallest number in a set. You can use brute force here but we can reduce the complexity of the problem to O(lg n) by augumenting a red-black or any self-balancing tree (where n is the number of elements in the set). We can also compute rank of any element in O(lg n) time. Let us consider a case where we are augumenting a red-black tree to store the addional information needed. Besides the usual attributes, we can store number of internal nodes in the subtree rooted at x(size of the subtree rooted at x including the node itself). Let x be any arbitary node of a tree.