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 freeWrite an algorithm that finds the \(m\) smallest numbers in a list of \(n\) numbers.
Suppose you have a computer that requires I minute to solve problem in stances of size \(n=1000 .\) What instance sizes can be run in 1 minute if you buy a new computer that runs 1000 times faster than the old one, assuming the following time complexities \(T(n)\) for our algorithm? (a) \(T(n) \in \Theta(n)\) (b) \(T(n) \in \Theta\left(n^{3}\right)\) (c) \(T(n) \in \Theta\left(10^{n}\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}{l} i=n_{i} \\ \text { while }(i>=1)\\{ \\ \qquad \begin{array}{c} j=i \\ \text { while }(j<=n) \end{array} \end{array} \\] < body of the inner while loop> \(\quad\) I/ Needs \(\Theta(1)\) \\[ j=2^{*} j \\] } \\[ i=|1 / 2| \\] }
Discuss the reflexive, symmetric, and transitive properties for asymptotic comparisons \((O, \Omega, \theta, o)\)
Presently we can solve problem instances of size 100 in 1 minute using algorithm A, which is a \(\Theta\left(2^{n}\right)\) algorithm. On the other hand, we will soon have to solve problem instances twice this large in 1 minute. Do you think it would help to buy a faster (and more expensive) computer?
What do you think about this solution?
We value your feedback to improve our textbook solutions.