Docsity

CS 361 Homework 1: Algorithms and Complexity, Assignments of Computer Science

Toggle sidebar
bg1
CS 361, HW1
Prof. Jared Saia, University of New Mexico
Feb 4, 2003, Due: Feb 11, 2003
You are encouraged to work with people in your group on this homework.
You are also free to ask a friend for help, or use any book or the web as a
resource. However, you must write up the work yourself.
If you have an older version of the book, check with a friend to make
sure you get the right numbers for exercises (the numbers are different for
the first and second editions)
1. CLRS Exercise 3.1-4: a) Is 2n+1 =O(2n)? b) Is 22n=O(2n)? Justify
your answers.
2. Exercise 1.2-2
3. Exercise 1.2-3
4. Problem 1-1
5. Using Figure 2-2 as a model, illustrate the operation of Insertion-Sort
on the array A={6,2,3,8,10,1}
6. Ex 2.1-3
7. Problem 2-2 (all 4 parts)
8. For each of the following, say whether or not a function f(n) exists
which meets the constraints. If a function exists, give an example
of such a function. (You may find it useful to refer to the precise
definition of O,o, Ω, etc given in lecture and in the book!)
(a) f(n) = o(n2) and f(n) = Ω(n)
(b) f(n) = o(nlog n) and f(n) = ω(n)
(c) f(n) = o(1)
(d) f(n) = O(log2n) and f(n) = Θ(log2n)
1
pf2

Partial preview of the text

Download CS 361 Homework 1: Algorithms and Complexity and more Assignments Computer Science in PDF only on Docsity!

CS 361, HW

Prof. Jared Saia, University of New Mexico

Feb 4, 2003, Due: Feb 11, 2003

You are encouraged to work with people in your group on this homework. You are also free to ask a friend for help, or use any book or the web as a resource. However, you must write up the work yourself. If you have an older version of the book, check with a friend to make sure you get the right numbers for exercises (the numbers are different for the first and second editions)

  1. CLRS Exercise 3.1-4: a) Is 2n+1^ = O(2n)? b) Is 2^2 n^ = O(2n)? Justify your answers.
  2. Exercise 1.2-
  3. Exercise 1.2-
  4. Problem 1-
  5. Using Figure 2-2 as a model, illustrate the operation of Insertion-Sort on the array A = { 6 , 2 , 3 , 8 , 10 , 1 }
  6. Ex 2.1-
  7. Problem 2-2 (all 4 parts)
  8. For each of the following, say whether or not a function f (n) exists which meets the constraints. If a function exists, give an example of such a function. (You may find it useful to refer to the precise definition of O,o, Ω, etc given in lecture and in the book!) (a) f (n) = o(n^2 ) and f (n) = Ω(n) (b) f (n) = o(n log n) and f (n) = ω(n) (c) f (n) = o(1) (d) f (n) = O(log^2 n) and f (n) = Θ(log^2 n) 1

(e) f (n) = Θ(log^100 10 n^5 ) and f (n) = Θ(log n) (f) f (n) = Θ(log^2 n^5 ) and f (n) = Θ(log^210 100 n) (g) f (n) = O(n10 log^ n) and f (n) = Ω(2log^2 n^10 )