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 , 2n
2. Using iteration, nd a tight bound for the soluti
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) How do you modify the IN SERT ION SORT procedure to so
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 maintaining a multi-set M . We want
to support the fol
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, each consisting of two numbers. The rst
number can be an
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) E and (v, w) E. Thus, G2 contains an edge between u an
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 that solves the selection problem SELECT(i) for an
arbitra
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 the range [0, 1] that represents the reliability of a
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 colored Red or Black and we maintained red-blue invaria
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 consists of a row of n elds, each consisting of two number
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.11 from textbook.
3. The square of a directed graph G =
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
height of a heap is the number of edges on the longest r
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 n 2
=
n(n+1)(2n+1) . 6
Collaboration is allowed, even e
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 design. Today we discuss priority queues and next time stru
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-black tree invariants
3. Augmented search trees
augment
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 wish to nd the i largest in sorted order using a comparis
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 structure M .
Insert(M, i): insert (one copy of) i in M .
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) if n 2
n(n+1)(2n+1)
.
6
Collaboration is allowed, even