CSE 101: Design and Analysis of Algorithms
Winter 2014
Homework 1
Due: January 16, 2014
1. Let G = (V, E) be a connected, undirected graph and suppose Ts = (V, F ) is a tree on G created by
exploring G using depth-rst search starting from vertex s. Vertex

Selected Solutions for Chapter 22: Elementary Graph Algorithms
Solution to Exercise 22.1-7
BB T .i; j / D
X
e 2E
T bie bej D
X
e 2E
bie bje
If i D j , then bi e bje D 1 (it is 1 1 or . 1/ . 1/) whenever e enters or leaves vertex i , and 0 otherwise. If i

Selected Solutions for Chapter 21: Data Structures for Disjoint Sets
Solution to Exercise 21.2-3
We want to show that we can assign O.1/ charges to M AKE -S ET and F IND -S ET and an O.lg n/ charge to U NION such that the charges for a sequence of these o

Selected Solutions for Chapter 15: Dynamic Programming
Solution to Exercise 15.2-5
Each time the l -loop executes, the i -loop executes n l C 1 times. Each time the i -loop executes, the k -loop executes j i D l 1 times, each time referencing m twice. Thu

Selected Solutions for Chapter 17: Amortized Analysis
Solution to Exercise 17.1-3
Let ci D cost of i th operation. ( i if i is an exact power of 2 ; ci D 1 otherwise : Operation 1 2 3 4 5 6 7 8 9 10 : : : Cost 1 2 1 4 1 1 1 8 1 1 : : :
n operations cost
n

Selected Solutions for Chapter 16: Greedy Algorithms
Solution to Exercise 16.1-4
Let S be the set of n activities. The obvious solution of using G REEDY-ACTIVITY-S ELECTOR to nd a maximum-size set S1 of compatible activities from S for the rst lecture hal

Selected Solutions for Chapter 14: Augmenting Data Structures
Solution to Exercise 14.1-7
Let A1 : : n be the array of n distinct numbers. One way to count the inversions is to add up, for each element, the number of larger elements that precede it in the

Selected Solutions for Chapter 13: Red-Black Trees
Solution to Exercise 13.1-4
After absorbing each red node into its black parent, the degree of each node black node is
2, if both children were already black, 3, if one child was black and one was red,

Selected Solutions for Chapter 12: Binary Search Trees
Solution to Exercise 12.1-2
In a heap, a nodes key is both of its childrens keys. In a binary search tree, a nodes key is its left childs key, but its right childs key. The heap property, unlike the b

Selected Solutions for Chapter 23: Minimum Spanning Trees
Solution to Exercise 23.1-1
Theorem 23.1 shows this. Let A be the empty set and S be any set containing u but not .
Solution to Exercise 23.1-4
A triangle whose edge weights are all equal is a grap

Selected Solutions for Chapter 24: Single-Source Shortest Paths
Solution to Exercise 24.1-3
If the greatest number of edges on any shortest path from the source is m, then the path-relaxation property tells us that after m iterations of B ELLMAN -F ORD, e

Akshay Laddha
Get free chart (kundli) at
http:/www.AstroSage.com
Basic Details
Sex
Date of Birth
Time of Birth
Day of Birth
Ishtkaal
Place of Birth
Friday
014-18-26
Amravati
Time Zone
5.5
Latitude
21 : 7 : N
Longitude
77 : 40 : E
Local Time Correction
War

Q1
a).
COMPARE(a,b)
if SEGMENTS-INTERSECT(x and y coordinates of end points of a and b)then
za, zb = z coordinates of the intersection point
if za > zb then
return ABOVE
else
return BELOW
else
return UNRELATED
b). Create a directed graph with vertices cor

CSCI 3650 - Analysis of Algorithms
Robert Hochberg - Spring 2010
Solutions to the First two Homeworks
2-4 Inversions
a. The permutation 23861 has ve inversions: (2, 1), (3, 1), (8, 6), (8, 1), (6, 1).
b. The permutation that has the most inversions is the

Discussion 7
Thursday, March 10
Dr. Nina Amenta
ECS 222A, Winter 2005
Summary
These notes contain two examples of primals and duals, as well as two more example reductions, as well as
hints for homework problem 1c.
Duality
We will look at the formal denit

Solutions for Introduction to algorithms second edition
Philip Bille
The author of this document takes absolutely no responsibility for the contents. This is merely a vague suggestion to a solution to some of the exercises posed in the book Introduction t

Selected Solutions for Chapter 26: Maximum Flow
Solution to Exercise 26.2-11
For any two vertices u and in G , we can dene a ow network Gu consisting of the directed version of G with s D u, t D , and all edge capacities set to 1. (The ow network Gu has V

Selected Solutions for Chapter 11: Hash Tables
Solution to Exercise 11.2-1
For each pair of keys k; l , where k l , dene the indicator random variable Xkl D I fh.k/ D h.l/g. Since we assume simple uniform hashing, Pr fXkl D 1g D Pr fh.k/ D h.l/g D 1=m, an

Selected Solutions for Chapter 9: Medians and Order Statistics
Solution to Exercise 9.3-1
For groups of 7, the algorithm still works in linear time. The number of elements greater than x (and similarly, the number less than x ) is at least l m 2n 1n 2 4 8

Introduction to Algorithms
Massachusetts Institute of Technology
Professors Erik Demaine and Sha Goldwasser
April 16, 2004
6.046J/18.410J
Handout 21
Problem Set 6 Solutions
This problem set is due in recitation on Friday, April 16.
Reading: Chapter 15, Ch

CS161: Design and Analysis of Algorithms
Summer 2004
Problem Set #4 Solutions
General Notes
Regrade Policy: If you believe an error has been made in the grading of your problem
set, you may resubmit it for a regrade. If the error consists of more than an

Analysis and Design of Algorithms
Singapore-MIT Alliance
Professors Hsu Wen Jing, Lee Wee Sun and Charles Leiserson
November 25, 2004
SMA5503
Handout 7
Problem Set 6 Solutions
Exercise 6-1. Do exercise 23.1-5 on page 566 of CLRS. Assume that e is part of

22.2-9
Let G =( V,E ) be a connected, undirected graph. Give an O(V + E)-time algorithm
to compute a path in G that traverses each edge in E exactly once in each
direction. Describe how you can find your way out of a maze if you are given a
large supply o

CPS 130 Homework 8 - Solutions
1. (CLRS 9.3-3) Show how Quicksort can be made to run in O(n log n) time in the worst case. Solution: Modify the Partition procedure of Quicksort to use the Select algorithm to choose the median of the input array as the piv