Exercises
k. We are asked: Is there a hitting set H g A for 3, BZ, . . . ,8, so that the
size of H is at most k?
10 Points Prove that Hitting Set is NP-complete.
.Consider an instance of the Satisfiability Problem, specified by clauses
1 C1, . . . ,Ck ove
Homework 1 (100 points)
Due in class on 12th September, 2016
There are 4 questions each worth 25 points. All questions are from this text book, Algorithms
by Dasgupta, Papadimitriou and Vazirani:
Answer questions 0.1, 0.2, and 0.3 from Chapter 0 of the te
Example Problem
Proof by Induction
Computational Tractability
Asymptotic Order of Growth
Common Running Times
Analysis of Algorithms
August 28, 2014
August 28, 2014
Analysis of Algorithms
Example Problem
Proof by Induction
Computational Tractability
Asymp
Priority Queues and Heaps
September 9, 2014
September 9, 2014
Priority Queues and Heaps
Motivation: Sort a List of Numbers
Sort
INSTANCE: Nonempty list
x1 , x2 , . . . , xn
SOLUTION: A permutation
yi yi+1 ,
for all 1
of integers.
y1 , y2 , . . . , yn
of
x
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Agenda
Today
Divide and Conquer Algorithms
Counting Inversions
Integer Multiplication
After that
We will discuss solutions
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Agenda
Today
Range-Searching Data Structure (K-D Trees, Range Trees)
After that
Dynamic Programming
Flow Algorithms
NP-Com
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Agenda
Last Lecture
Greedy Algorithms Introduction
Dijkstras algorithm
This Lecture
Greedy algorithms for Minimum Spanning
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Exam
19th October, 2015 4:00-5:15
Three Questions (100 points)
Question 1 (50 points): 10 small questions which quiz your und
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Logistics
Project Phase 1 to be released on 7th ; due on 25th
Homework 3 to be released on 7th ; Due on 14th
Exam on the 19th
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Logistics
Project Phase 1 to be released on 7th ; due on 25th
Homework 3 to be released on 7th ; Due on 14th
Exam on the 19th
Homework 3 (100 points)
Due date: 17th October, 2016
1) (17+8 points) In this exercise, we will derive an alternate proof for Kruskals algorithm.
We assume G is a connected, weighted and undirected graph where each edge has a
distinct weight, i.e., no two
Homework 6 (100 points)
Due in class on 7th December, 2016
There are 4 questions in this homework.
1) (20 points) For a bipartite graph ( , ), let be a maximum cardinality matching
and let M be any other matching. Recollect that the graph ( , ) consists
o
Homework 6 Solutions
1)
The question asks to show that there are exactly |M 0 | |M | odd length paths in G(A
B, M 0 M ). As most of you observed, this graph consists of cycles, paths and isolated
vertices. Cycles and even length paths have same number of
Solutions to Homework 5
CS 4104 (Fall 2016)
Problem 1 (20 points) Solve exercise 1 in Chapter 6 (pages 312313) of your textbook.
Solution:
(a) Consider a path with three nodes, weighted 2, 3, and 2 respectively. The greedy algorithm will
pick the node in
Homework 7 Solutions
Problem 1 (10 points) Solve exercise 6 in Chapter 8 (page 507) of your textbook.
Solutions: First, the Monotone Satisfiaability problem is in N P. As stated in the
problem, we have k clauses and n Boolean variables. The certificate t
CS4104 Homework 4 Solutions
1
Data structure. The data structure to be used essentially keeps the array and just adds
pointers at each array element. This pointer will point to the first value greater than or
equal to the current value in the next subset
CS4104 Homework 2 Solutions
1
From question we have:
X xi + yj = Y yj + xi
(1)
Y X
yj =
+ xi
(2)
2
So, in other words we should find yj which satisfies the former equation. To do that, we
start with computing the sums X and Y , which takes O(n) and O(m).
Homework 5 (100 points) Due 16th November
Problem 1, 2 and 3 are 20 points each and problem 4 is 40 points. Check resources on piazza for
the description of problem 1 and 2.
CS4104 Homework 3 Solutions
1
a. Given T =< e1 , e2 , . . . , en1 > and T =< e1 , e2 , . . . , en1 > we want to show that
for every i, the weight of ei is less than or equal to the weight of ei .
Assume for contradiction that ei < ei . Consider two differ
CS4104 Homework 1 Solution
0.1
(a) f (n) = (g(n)
(b) f (n) = O(g(n)
(c) f (n) = (g(n) note that polynomial term dominates logarithmic function
(d) f (n) = (g(n)
(e) f (n) = (g(n)
(f) f (n) = (g(n)
(g) f (n) = (g(n)
(h) f (n) = (g(n)
(i) f (n) = (g(n)
(j)
Homework 4 (100 points)
Due in class on 31st October, 2016
There are 4 questions in this homework.
Problem 2 [30 points] We are given a set S containing n vertical line segments and a set
R containing n horizontal line segments. No two line segments of S
Homework 2
Due date: 23rd September, 2016 (during office hours 9-11AM)
1) (25 points) Consider two sums, = 1 + 2 + + and = 1 + 2 + + . Give
an algorithm that finds indices and such that swapping and makes the two sums
equal, that is, + = + , if they exist
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Logistics
Homework 2 released. Due on 28th September.
Work in groups of three.
5 questions with varying levels of difficulty
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Quiz 2
Performance was generally on the lower side
Scores above 14 are satisfactory.
Anyone with single digit score was unpre
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2015
Logistics
Quiz starts at 4:30
Minimizing Lateness
Single resource processing one job at a time
Job requires units of processi
Homework 6
CS 4104 (Spring 2017)
Assigned on April 17, 2017.
Submit PDF solutions on Canvas by the
beginning of class on April 24, 2017.
Instructions:
The Honor Code applies to this assignment as follows:
You can pair up with another student to solve th
CS 2506 Computer Organization II
MIPS 4: Pipeline
You may work in pairs for this assignment. If you choose to work with a partner, make sure only one of you submits a
solution, and you paste a copy of the Partners Template that contains the names and PIDs
Homework 3
CS 4104 (Spring 2017)
Assigned on Wednesday, February 15, 2017.
Submit a PDF file containing your solutions on Canvas by the beginning of class on
Monday, February 27, 2017. Yes, you have 12 days to work on this homework assignment.
Instruction
Jacob Weate
No Partner
1. False, it is possible that the stable matching does not contain a pair that both rank their
partner at number one. For example if male1 has women1 and male2 has women2 as his
first choice but women1 has male2 has her first choice
CS4104: Algorithm and Data Analysis
Sharath Raghvendra
Assistant Professor, Dept. of Computer Science,
Virginia Tech
Fall 2016
Logistics
Homework 2 to be released tomorrow; Due on 21st September.
Agenda
Today
Closest-Pair Problem
Next Lecture
Divide