CS F364
Design & Analysis of Algorithms
Sundar B.
Comparison:
2/21/2015
ALGORITHM DESIGN TECHNIQUES
Top-Down Design vs. Bottom-up Design
Divide-and-Conquer vs. Dynamic Programming
CSIS, BITS, Pilani
1
TOP DOWN DESIGN VS. BOTTOM UP DESIGN
Strategy: Combine
Birla Institute of Technology & Science, Pilani
Work-Integrated Learning Programmes Division
First Semester 2015-2016
EC-2 Regular Mid-Semester Test
Course Title
Course No
Total
Nature of Exam
Duration
:
:
:
:
:
Data Structures and Algorithms
SS ZG 519
35
Birla Institute of Technology & Science, Pilani
Work-Integrated Learning Programmes Division
First Semester 2015-2016
EC-3 Regular Comprehensive Examination
Course Title
Course No
Total
Nature of Exam
Duration
:
:
:
:
:
Data Structures and Algorithms
SS Z
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 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
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 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 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
Selected Solutions for Chapter 8: Sorting in Linear Time
Solution to Exercise 8.1-3
If the sort runs in linear time for m input permutations, then the height h of the portion of the decision tree consisting of the m corresponding leaves and their ancestor
Selected Solutions for Chapter 7: Quicksort
Solution to Exercise 7.2-3
PARTITION does a worst-case partitioning when the elements are in decreasing order. It reduces the size of the subarray under consideration by only 1 at each step, which weve seen has