Docsity

Assignment One Questions Unsolved - Fundamental Algorithms | CS 231, Assignments of Algorithms and Programming

Toggle sidebar
bg1
CS231 Algorithms Handout # 3
Prof. Lyn Turbak September 11, 2001
Wellesley College
Problem Set 1
Due: Friday, September 21
Reading: Carefully read CLRS Chapters 1–3 and Sections 4.1 & 4.2. Skim Appendices A & B.
(CLR: read Chapters 1 & 2 and Sections 4.1 & 4.2, and skim Chapter 3 and Sections 5.1–5.3.)
Sugggested Problems: CLRS 1.2-3, 1-1, 2.3-6, 2-4 (CLR 1.3-6, 1.4-2, 1-1, 1-3) (These are
problems from the book that you should think about, but you should not write them up or turn
them in! At least one suggested problem will be on each exam. Some suggested problems will be
easy while others will be quite challenging!)
Required Problems: You should write up and turn in the solutions to the problems listed below:
The points awarded per problem are given in brackets.
Problem 1 [15] CLRS Problem 3-2 (p. 58) (CLR 2-2, p. 38).
Problem 2 [25] Do CLRS Problem 3-3, part a, (p. 58) (CLR 2-3, p. 38–39), but for the following
24 functions (not the 30 given in the text):
nnlg n(√2)lg nn2n!n3
lg2n2(2n)ln(ln n)1 2
lg n4lg n
(n+1)! √ln nn2nn·lg n2(2n+1)
1
n2n+1 √n3nln nn·2n
Problem 3 [10]
a. [5] Suppose algorithm Ahas worst-case running time O(n) and algorithm Bhas running
time O(n2). What can you say about the relative performance of the algorithms?
b. [5] Repeat part a for worst-case running times Θ(n)andΘ(n2).
Problem 4 [10] The natural numbers Nare the the non-negative integers: N={0,1,2,...}.Let
anatural number function be a function from Nto N– i.e., a that takes a natural number as an
input and returns a natural number as an output.
Find two natural number functions f(n)andg(n) such that f(n)isnotO(g(n)) and g(n)is
not O(f(n)).
Problem 5 [40] Use the recursion tree method to solve the following recurrences. In all cases,
you may assume that T(n)=0forn<1. Express your solutions in Θ notation. Show your work.
(Note that parts d through g generalize examples discussed in class.)
1
pf3

Partial preview of the text

Download Assignment One Questions Unsolved - Fundamental Algorithms | CS 231 and more Assignments Algorithms and Programming in PDF only on Docsity!

CS231 Algorithms Handout # 3 Prof. Lyn Turbak September 11, 2001 Wellesley College

Problem Set 1

Due: Friday, September 21

Reading: Carefully read CLRS Chapters 1–3 and Sections 4.1 & 4.2. Skim Appendices A & B. (CLR: read Chapters 1 & 2 and Sections 4.1 & 4.2, and skim Chapter 3 and Sections 5.1–5.3.)

Sugggested Problems: CLRS 1.2-3, 1-1, 2.3-6, 2-4 (CLR 1.3-6, 1.4-2, 1-1, 1-3) (These are problems from the book that you should think about, but you should not write them up or turn them in! At least one suggested problem will be on each exam. Some suggested problems will be easy while others will be quite challenging!)

Required Problems: You should write up and turn in the solutions to the problems listed below: The points awarded per problem are given in brackets.

Problem 1 [15] CLRS Problem 3-2 (p. 58) (CLR 2-2, p. 38).

Problem 2 [25] Do CLRS Problem 3-3, part a, (p. 58) (CLR 2-3, p. 38–39), but for the following 24 functions (not the 30 given in the text):

nn^ lg n (

2)lg^ n^ n^2 n! n^3 lg^2 n 2 ( n (^) ) ln(ln n) 1 2 lg^ n^4 lg^ n (n + 1)!

ln n n 2 n^ n · lg n 2 ( n+1 (^) ) 1 n 2

n+1 √n 3 n (^) ln n n · 2 n

Problem 3 [10]

a. [5] Suppose algorithm A has worst-case running time O(n) and algorithm B has running time O(n^2 ). What can you say about the relative performance of the algorithms?

b. [5] Repeat part a for worst-case running times Θ(n) and Θ(n^2 ).

Problem 4 [10] The natural numbers N are the the non-negative integers: N = { 0 , 1 , 2 ,... }. Let a natural number function be a function from N to N – i.e., a that takes a natural number as an input and returns a natural number as an output. Find two natural number functions f (n) and g(n) such that f (n) is not O(g(n)) and g(n) is not O(f (n)).

Problem 5 [40] Use the recursion tree method to solve the following recurrences. In all cases, you may assume that T (n) = 0 for n < 1. Express your solutions in Θ notation. Show your work. (Note that parts d through g generalize examples discussed in class.)

a. T (n) = 3T (n/3) + 1

b. T (n) = 3T (n/3) + n

c. T (n) = 4T (n/2) + n

d. T (n) = T (n − k) + 1, k > 0

e. T (n) = T (n − k) + n, k > 0

f. T (n) = T (a · n) + 1, 0 < a < 1

g. T (n) = T (a · n) + n, 0 < a < 1

h. T (n) = T (a · n) + T (b · n) + n, 0 < (a + b) < 1

Extra Credit 1 [20]: CLRS Exercise 2.3-7 (CLR 1.3-7).