Question
1. Prove or disprove formally: (a) The largest even prime number is 2. For the following, study the definitions in the notes on Binary Trees.
1. Prove or disprove formally:
(a) The largest even prime number is 2.
For the following, study the definitions in the notes on Binary Trees.
(b) The number of leaf nodes (nodes with no children) in a full binary tree of height h is exactly 2^h .
(c) The total number of nodes in any binary tree of height h is less than 2^(h+1)
(d) The height of a complete binary tree containing N nodes is [log2 N].
(e) The height of any binary tree containing N nodes is less than N.
(f) The number of internal nodes in a complete binary tree of N nodes is [N/2].
2. Prove or disprove formally that the number of digits needed in the binary representation of any positive number N is [log2 N].
3. Algorithm A has running time TA(n) = 10^6 + 10^4 n + 10^5 n^2 and algorithm B has running time TB(n) = 3 n^3 , where n is the number of values the algorithms processes. Give the big O equations for their running times and state which algorithm is fastest for very large n.
4. Algorithm C has running time TC(n) = O(n), algorithm D has running time TD(n) = O(log n), and algorithm E has running time TE(n) = O( sqrt(n)). Which algorithm is the fastest and which is the slowest for very large n? Justify your answer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started