Chapter 1: Problem 8
Write an algorithm that determines whether or not an almost complete binary tree is a heap.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 1: Problem 8
Write an algorithm that determines whether or not an almost complete binary tree is a heap.
All the tools & learning materials you need for study success - in one app.
Get started for free
Write a linear-time algorithm that sorts \(n\) distinct integers ranging from 1 to 500 , inclusive. (Hint: Use a 500 -element array.)
Justify the correctness of the following statements assuming that \(f(n)\) and \(g(n)\) are asymptotically positive functions. (a) \(f(n)+g(n) \in O(\max (f(n), g(n))\) (b) \(f^{2}(n) \in \Omega(f(n))\) (c) \(f(n)+o(f(n)) \in \Theta(f(n)),\) where \(o(f(n))\) means any function \(g(n) \in\) \(o(f(n))\)
Write an algorithm that finds both the smallest and largest numbers in a list of \(n\) numbers, Try to find a method that does at most about \(1.5 n\) comparisons of array items.
Using the definitions of \(O\) and \(\Omega\), show that \\[ 6 n^{2}+20 n \in O\left(n^{3}\right) \quad \text { but } \quad 6 n^{2}+20 n \notin \Omega\left(n^{3}\right) \\]
Show that the function \(f(n)=\left|n^{2} \sin n\right|\) is in neither \(O(n)\) nor \(\Omega(n)\)
What do you think about this solution?
We value your feedback to improve our textbook solutions.