Coder Social home page Coder Social logo

homework-2's Introduction

Homework 2

  1. Problem 2.3-7:
    Describe a Θ(nlogn) time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x.

    • 第十二組
  2. Problem 2-1: Insertion sort on small arrays in merge sort
    Although merge sort runs in Θ(nlogn) worst-cast time and insertion sort runs in Θ(n^2) worst-cast time, the constant factors in insertion sort make it faster for small n. Thus, it makes sense to use insertion sort within merge sort when sub-problems become sufficiently small. Consider a modification to merge sort in which n/k sub-lists of length k are sorted using insertion sort and then merged using the standard merging mechanism, where k is a value to be determined.

    • Show that the n/k sub-lists, each of length k, can be sorted by insertion sort in Θ(nk) worst-case time.
    • Show that the sub-lists can be merged in Θ(nlog(n/k)) worst-case time.
    • Given that the modified algorithm runs in Θ(nk+nlog(n/k)) worst-case time, what is the largest asymptotic (Θ-notation) value of k as a function of n for which the modified algorithm has the same asymptotic running time as standard merge sort?
    • How should k be chosen in practice?
    • 第十一組
  3. Problem 3-2: Relative asymptotic growths
    Indicate, for each pair of expressions (A, B) in the table below, whether A is O, o, Ω, ω, or Θ of B. Assume that k ≥ 1, ε > 0, and c > 1 are constants. Your answer should be in the form of the table with "yes" or "no" written in each box.

    • 第八組
A B O o Ω ω Θ
log^kn n^ε
n^k c^n
sqrt(n) n^sin(n)
2^n 2^(n/2)
n^logc c^ln(n)
log(n!) log(n^n)
  1. Ext. 2-1
    Show that there exists two non-negative functions f and g (i.e. f, g : NR*) such that f≠O(g), f≠θ (g), and f≠Ω(g).

    • 第五組
  2. Problem 3-3 Ordering by asymptotic growth rates

    • Rank the following functions by order of growth; that is, find an arrangement g1, g2, …, g30 of the functions satisfying g1 = Ω(g2), g2 = Ω(g3), …, g29 = Ω(g30). Partition your list into equivalence classes such that functions f(n) and g(n) are in the same class if and only if f(n) = Ѳ(g(n)).
      log(log^(n)), 2^(log^(n)), (sqrt(2))^logn, n^2, n!, (logn)!,
      (3/2)^n, n^3, log^2(n), log(n!), 2^2^n, n^(1/logn),
      ln(ln(n)), log^*(n), n·2^n, n^loglogn, ln(n), 1
      2^logn, (logn)^logn, e^n, 4^logn, (n+1)!, sqrt(logn),
      log^*logn, 2^sqrt(2logn), n, 2^n, nlogn, 2^2^(n+1)
    • Give an example of a single non-negative function f(n) such that for all functions gi(n) in part (a), f(n) is neither O(gi(n)) nor Ω(gi(n)).
    • 第四組
  3. Solve the recurrence T(n)=2T(sqrt(n))+1 by making a change of variables. Your solution should be asymptotically tight. Do not worry about whether values are integral.

    • 第十九組
  4. Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n)=3T(floor(n/2))+n. Use the substitution method to verify your answer.

    • 第二十組

homework-2's People

Contributors

c910335 avatar

Watchers

James Cloos avatar YyWang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.