v CSOR 4231: Homework

Homework 1

  • Assigned: Tuesday, January 29,2019
  • Due: Friday, February 8, 2019
  • General Instructions: 
  1. Please review the homework and grading policy outlined in the course information and homework page.
  2. You must also write down with whom you worked on the assignment, and any sources used.
  3. Start early, be concise but rigorous, and enjoy!
  • Specific Instructions:
  1. Be sure to review any parts of Chapters 1-4 with which you are not familiar.
  2. All logs are base 2 unless otherwise specified.
  3. Unless otherwise specified, all problems and exercises are from CLRS, Introduction to Algorithms, 3rd edition.
  • Problems to do but not hand in:
    1. Problem 2-3.
    2. Problem 4-1.
  • Problems To Hand In:
    1. Show that for any positive real constants b, and d, (n^2 - b)d = Θ(n2d).
    2. Is 34n = O(24n)? Is 34n = 2O(4n)
    3. Exercise 3.2-4
  1. Problem 2-4. Inversions.
  2. Problem 3-4 b, d, e, g . Big-O and other notation.
  3. Place the following functions by order of growth, from smallest to largest. For each adjacent pair in the list, give a proof that the earlier one is assymptotically smaller than (or equal to ) the second, by giving a big-O proof.
      • n2
      • n0.8
      • 2n
      • 4lg lg n
      • lg4 n
      • 4lg n
      • n2 + n1.99 lg n
      • 16 n
      • (lg n)lg n / lg lg n
      • 6n/2
  4. Problem 4-3. c, e, i, j. For each recurrence, provide an upper bound. If the recurrence cannot be solved by the master method, you must justify the solution via a substitution proof or by drawing a recursion tree.
  5. You are given as input an array A[1..n], with n entries. Furthermore, you know that, the array consists of a series of 0's followed by a series of 1's, but you don't know how many of each there are. Your goal is to find the first 1 in the array. There is a cost associated with checking the value of an array. Each time you check a value and it turns out to be 0, you must pay 1 dollar. If value turns out to be 1, you have to pay 1 "Famous Algorithmist Trading Card (FATC)". In each of the parts of this question, you will have some number of dollars and some number of FATC. You must give an algorithm which will return the index of the first (lowest index 1) which works given your resources. For each part write pseudocode and explain why your algorithm works, given your resources.
    1. You have n dollars and 1 FATC
    2. You have 1 dollars and n FATC
    3. You have O(log n) dollars and O(log n) FATC
    4. You have 2 dollars and O(n .5 ) FATC
    5. You have k dollars and O(n1/k) FATC, for some constant k.