CSci 231 Homework 1
Algorithm Analysis
Reading: CLRS Chapters 1,2,3, 4 and A.1
1. Arrange the following functions in ascending order of growth rate:
n
2
2 log n , 2n , n4/3 , n(log n)3 , nlog n , 22 ,
CPS 231 Homework 1
Insertion sort and Growth of Functions
CLRS Chapter 1, 2 and 3, Appendix A
Write and justify your answers on this sheet in the space provided.1
Exercises (suggested)
1. (CLRS 2.1-2)
CSci 231 Homework 6
Red Black Trees
CLRS Chapter 13 and 14
1. Problem 13-1 (persistent dynamic sets).
2. Problem 13-3 (AVL trees) only part a and b.
3. In this problem we consider a data structure for
CSci 231 Homework 7
Dynamic Programming and Greedy Algorithms
CLRS Chapter 15 and 16
Use a (single) separate sheet of paper for each problem. Be concise.
1. A game-board consists of a row of n elds, e
CSci 231 Homework 9
Graph Algorithms
CLRS Chapter 22, 24
1. [22.1-5] The square of a directed graph G = (V, E) is a graph G2 = (V, E 2 ) such that (u, w) E 2 if
and only if, for some v V , both (u, v)
CSci 231 Homework 4
Selection and Divide-and-conquer
CLRS Chapter 9
1. (CLRS 9.3-5) Suppose that you have a black-box worst-case linear-time median subroutine.
Give a simple, linear-time algorithm tha
CSci 231 Homework 10
Graph Algorithms
CLRS Chapter 24, 25
1. (CLRS 25.2-4) We are given a directed graph G = (V, E) on which each edge (u, v) has an associated
value r(u, v), which is a real number in
Augmented Search Trees
(CLRS 14)
1
Red-Black Trees
Last time we discussed red-black trees:
Balanced binary treesall elements in left (right) subtree of node x are < x (> x).
e
<e
> e
Every node is
CSci 231 Homework 5
Greedy and Dynamic Programming
Write each problem on a separate page. You will be graded on the clarity of the solution
as well as correctness and completeness.
1. A game-board con
CSci 231 Homework 4
Graphs
Write each problem on a separate page. You will be graded on the clarity of the solution
as well as correctness and completeness.
1. Problem 3.7 from textbook.
2. Problem 3.
CSci 231 Homework 2
1
Practice problems
These are intended to help you study. You do not need to turn them in.
1. What are the minimum and maximum number of elements in a heap of height h? Note: the
h
CSci 231 Homework 2
Recurrences CLRS Chapter 4
Write and justify your answers on this sheet in the space provided.1 1. Solve the recurrence: T (n) = Hint: use
n 2 i=1 i
1 if n = 1 T (n 1) + n(n 1) if
Heaps. Heapsort.
(CLRS 6)
1
Introduction
We have discussed several fundamental algorithms (sorting, selection, etc) We will now turn to data structures; They play an important role in algorithms desi
CSci 231 Review problems
Here is a list of topics for the nal.
1. Binary search trees (INSERT, DELETE, SEARCH, MIN, MAX, PRED, SUCC)
binary search tree property
tree walks
2. Red-black trees
red-bl
CSci 231 Homework 2
1. Give an O(n lg k)-time algorithm to merge k sorted lists into one sorted list, where n is the
total number of elements in all the input lists.
2. Given a set of n numbers, we wi
CSci 231 Homework 3
Binary search trees
1. In this problem we consider a data structure for maintaining a multi-set M . We want
to support the following operations:
Init(M ): create an empty data str
CSci 231 Homework 2
Recurrences
CLRS Chapter 4
Write and justify your answers on this sheet in the space provided.1
1. Solve the recurrence: T (n) =
Hint: use
1
n
2
i=1 i
=
1
if n = 1
T (n 1) + n(n 1)