Chapter 1: Problem 5
Write an algorithm that finds the greatest common divisor of two integers.
Chapter 1: Problem 5
Write an algorithm that finds the greatest common divisor of two integers.
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.\) e. \(\lg ^{3} n \in o\left(n^{0.5}\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)$$
Let \(p(n)=a_{k} n^{k}+a_{k-1} n^{k-1}+\ldots+a_{1} n+a_{0},\) where \(a_{k}>0 .\) Using the Properties or order in Section \(1.4 .2,\) show that \(p(n) \in \Theta\left(n^{k}\right)\)
Give a \(\Theta(n \text { lg } n)\) algorithm that computes the reminder when \(x^{n}\) is divided by \(p .\) For simplicity, you may assume that \(n\) is a power of 2 That is, \(n=2^{k}\) for some positive integer \(k\)
Write a \(\Theta(n)\) algorithm that sorts \(n\) distinct integers, ranging in size between 1 and \(k n\) inclusive, where \(k\) is a constant positive integer. (Hint: Use a kn-element array.)
What do you think about this solution?
We value your feedback to improve our textbook solutions.