Deriving time complexity of Binary tree and AVL tree, step
by step.
Answers were Sorted based on User's Feedback
Answer / tilak chandan
Lemma: A subtree rooted at node v has at least 2bh(v) − 1 internal nodes.
Proof of Lemma (by induction height):
Basis: h(v) = 0
If v has a height of zero then it must be null, therefore bh(v) = 0. So:
2bh(v) − 1 = 20 − 1 = 1 − 1 = 0
Inductive Step: v such that h(v) = k, has at least 2bh(v) − 1 internal nodes implies that v' such that h(v') = k+1 has at least 2bh(v') − 1 internal nodes.
Since v' has h(v') > 0 it is an internal node. As such it has two children each of which have a black-height of either bh(v') or bh(v')-1 (depending on whether the child is red or black, respectively). By the inductive hypothesis each child has at least 2bh(v') − 1 − 1 internal nodes, so v' has at least:
2bh(v') − 1 − 1 + 2bh(v') − 1 − 1 + 1 = 2bh(v') − 1
internal nodes.
Using this lemma we can now show that the height of the tree is logarithmic. Since at least half of the nodes on any path from the root to a leaf are black (property 4 of a red black tree), the black-height of the root is at least h(root)/2. By the lemma we get:
Therefore the height of the root is O(log(n)).
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / pudwallis gudzinsky
I do not know the answer either. In fact, I do not believe
that a question was asked. Therefore, I feel that this is
a trick non-question. If the question was "Do I like tater
tots?" Indeed the answer would be a resounding Yes and I
am 100 percent certain that this answer is correct.
If there are girls available in the room, I would not like
strike with them.
Is This Answer Correct ? | 5 Yes | 22 No |
Answer / haresh
Actually i was searching for the same answer as i dont know
what the answer is.. But yah if there are girls in ur room i
will be happy striking with them lol
Is This Answer Correct ? | 1 Yes | 19 No |
Answer / ssss ss
I do not know what the answer is .I am subhani and you are
not my friend .However I do not the answer.But you do not
know the answer.You have already told me that i have already
strike with the girls available in the room.
Is This Answer Correct ? | 6 Yes | 34 No |
Hello, I am trying to write a program in c++ which accepts month and year from the user and prints the calender. So please tell me the algorithm and what is the calender logic.
what is the best algorithm to sort out unique words from a list of more than 10 million words(1 crore+)? we need the best technique in the terms of execution time.
What output does the following code generate? Why? What output does it generate if you make A::Foo() a pure virtual function? class A { A() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; class B : public A { B() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; int main(int, char**) { A objectA; B objectB; return 0; }
A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E
Here's the programm code: int magic(int a, int b) { return b == 0 ? a : magic(b, a % b); } int main() { int a, b; scanf("%d%d", &a, &b); printf("%d\n", magic(a, b)); return 0; } on input stream we have integers 4, 45 What's the output integer? How many times will be initiated "magic" function?
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
We need to write the function to check the password entered is correct or not based on the following conditions.. a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters and any special characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character
Code for Method of Handling Factorials of Any Size?
write a program to sort 'n' elemnts using bubble sort
how to write a program that opens a file and display in reverse order?
Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?
2 Answers ABC, Qatar University,
readers and writers problem