CMSC 351 Homework 2: Computer Science Problem Solving - Prof. Clyde P. Kruskal, Assignments of Algorithms and Programming

A computer science homework assignment from summer 2009 for cmsc 351, focusing on problem-solving and algorithm analysis. It includes various problems related to big o notation, algorithm efficiency, and the borogove problem. Students are required to analyze and compare the efficiency of different algorithms and programs.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-fd0
koofers-user-fd0 šŸ‡ŗšŸ‡ø

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Summer 2009 CMSC 351: Homework 2 Clyde Kruskal
Due at the start of class Wednesday, June 10, 2009.
Problem 1. Professor Hilbert invents a program that uses exactly 1000n3operations to
solve the borogove problem of size n. Professor Poincare invents a program that uses
1.5n/105operations to solve the same problem.
(a) Assume that you are willing to run Hilbert’s program for some specific amount
of time. Assume that your computer speed increases by a factor of 10. How
much larger a problem can you solve in the same amount of time? Show your
work.
(b) Assume that your computer executes one billion operations per second. Approx-
imately how large a problem can you solve in a year? Show your work (but not
the arithmetic).
(c) Assume that you are willing to run Poincare’s program for some specific amount
of time. Assume that your computer speed increases by a factor of 10. How
much larger a problem can you solve in the same amount of time? Show your
work.
(d) Assume that your computer still executes one billion operations per second. Ap-
proximately how large a problem can you now solve in a year? Show your work
(but not the arithmetic).
(e) Whose program should you use if you are going to run it for a year?
(f) For approximately what values of nis Professor Hilbert’s program faster than
Professor Poincare’s? Show your work.
Problem 2. Show the following. In each of (a), (b), and (c) state specific values of the
constants (e.g. c1,c2,n0) you used to satisfy the conditions, and show how you arrived
at the values.
(a) 2n2+ 2n+ 6 = O(n2āˆ’2n+ 4)
(b) 4n3āˆ’3n2+ 8 = Θ(n3)
(c) 2n2+ 5n(lg n)3=O(n2) [Hint: Find n0such that (lg n)3≤n, for all n≄n0.]
(d) nlog n=o(n1.5)
Problem 3. For each pair of expressions (A, B ) below, indicate whether Ais O,o, Ω, ω,
or Θ of B. Note that zero, one or more of these relations may hold for a given pair;
list all correct ones.
A B
(a)n100 2n
(b) (log n)12 √n
(c)√n ncos(Ļ€n/8)
(d) 10n100n
(e)nlog n(log n)n
(f) log (n!) nlog n
pf2

Partial preview of the text

Download CMSC 351 Homework 2: Computer Science Problem Solving - Prof. Clyde P. Kruskal and more Assignments Algorithms and Programming in PDF only on Docsity!

Summer 2009 CMSC 351: Homework 2 Clyde Kruskal

Due at the start of class Wednesday, June 10, 2009.

Problem 1. Professor Hilbert invents a program that uses exactly 1000n^3 operations to solve the borogove problem of size n. Professor Poincare invents a program that uses

  1. 5 n/ 105 operations to solve the same problem.

(a) Assume that you are willing to run Hilbert’s program for some specific amount of time. Assume that your computer speed increases by a factor of 10. How much larger a problem can you solve in the same amount of time? Show your work. (b) Assume that your computer executes one billion operations per second. Approx- imately how large a problem can you solve in a year? Show your work (but not the arithmetic). (c) Assume that you are willing to run Poincare’s program for some specific amount of time. Assume that your computer speed increases by a factor of 10. How much larger a problem can you solve in the same amount of time? Show your work. (d) Assume that your computer still executes one billion operations per second. Ap- proximately how large a problem can you now solve in a year? Show your work (but not the arithmetic). (e) Whose program should you use if you are going to run it for a year? (f) For approximately what values of n is Professor Hilbert’s program faster than Professor Poincare’s? Show your work.

Problem 2. Show the following. In each of (a), (b), and (c) state specific values of the constants (e.g. c 1 , c 2 , n 0 ) you used to satisfy the conditions, and show how you arrived at the values.

(a) 2n^2 + 2n + 6 = O(n^2 āˆ’ 2 n + 4) (b) 4n^3 āˆ’ 3 n^2 + 8 = Θ(n^3 ) (c) 2n^2 + 5n(lg n)^3 = O(n^2 ) [Hint: Find n 0 such that (lg n)^3 ≤ n, for all n ≄ n 0 .] (d) n log n = o(n^1.^5 )

Problem 3. For each pair of expressions (A, B) below, indicate whether A is O, o, Ī©, ω, or Θ of B. Note that zero, one or more of these relations may hold for a given pair; list all correct ones. A B (a) n^100 2 n (b) (log n)^12

n (c)

n ncos(Ļ€n/8) (d) 10 n^100 n (e) nlog^ n^ (log n)n (f ) log (n!) n log n

Problem 4. Consider the insertion sort algorithm. (Either version will suffice.)

(a) Give a double summation for the number of moves in the worst case. (b) Simplify the summation. (c) Give a double summation for the number of moves in the average case. (d) Simplify the summation.