Chapter 1: Problem 2
Write an algorithm that finds the \(m\) smallest numbers in a list of \(n\) numbers.
/*! 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 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 free
Show 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)\)
Give an algorithm for the following problem. Given a list of \(n\) distinct positive integers, partition the list into two sublists, each of size \(n / 2,\) such that the difference between the sums of the integers in the two sublists is minimized. Determine the time complexity of your algorithm. You may assume that \(n\) is a multiple of 2
Write an algorithm that finds the largest number in a list (an array) of \(n\) numbers.
Let \(p(n)=a_{4} n^{4}+a_{k-1} n^{k-1}+\dots a_{1} n+a_{0},\) where \(a_{k}>0 .\) Using the Properties of Order in Section \(1.4 .2,\) show that \(p(n) \in \Theta\left(n^{k}\right)\)
Group the following functions by complexity category. $$n \ln n \quad(\lg n)^{2} \quad 5 n^{2}+7 n \quad n^\frac{5}{2} $$ $$n ! \quad 2^{n !} \quad 4^{n} \quad n^{n} \quad n^{n}+\ln n$$ $$5^{\text {Ig n}} \quad \lg (n !) \quad(\lg n) ! \quad \sqrt{n} \quad e^{n} \quad 8 n+12 \quad 10^{n}+n^{20}$$
What do you think about this solution?
We value your feedback to improve our textbook solutions.