Chapter 1: Problem 2
Write an algorithm that finds the \(m\) smallest numbers in a list of \(n\) numbers.
Chapter 1: Problem 2
Write an algorithm that finds the \(m\) smallest numbers in a list of \(n\) numbers.
All the tools & learning materials you need for study success - in one app.
Get started for freeShow the correctness of the following statements. (a) \(\lg n \in O(n)\) (b) \(n \in O(n \lg n)\) (c) \(n \lg n \in O\left(n^{2}\right)\) (d) \(2^{n} \in \Omega\left(5^{\ln n}\right)\) (c) \(\lg ^{3} n \in o\left(n^{a \cdot 5}\right)\)
What is the time complexity \(T(n)\) of the nested loops below? For simplicity, you may assume that \(n\) is a power of \(2 .\) That is, \(n=2^{k}\) for some positive integer \(k\) \(:\) \\[ \begin{array}{} \text { for }(i=1 ; i<=n, i++)\\} \\ \ \begin{array}{} j=n \\ \text { while }(j>=1)\\{ \end{array} \end{array} \\] < body of the while loop> \(\quad\) I/ Needs \(\Theta(1)\) \\[ j=\lfloor j / 2\rfloor \\] } }
Algorithm A performs \(10 n^{2}\) basic operations, and algorithm B performs \(300 \ln n\) basic operations. For what value of \(n\) does algorithm \(\mathrm{B}\) start to show its better performance?
Show directly that \(f(n)=n^{2}+3 n^{3} \in \Theta\left(n^{3}\right) .\) That is, use the definitions of \(O\) and \(\Omega\) to show that \(f(n)\) is in both \(O\left(n^{3}\right)\) and \(\Omega\left(n^{3}\right)\)
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) \\]
What do you think about this solution?
We value your feedback to improve our textbook solutions.