SlideShare a Scribd company logo
For any Assignment related queries, call us at : - +1 678 648 4277
visit : - https://www.programminghomeworkhelp.com/, or
Email : - support@programminghomeworkhelp.com
Problem 1. True or False.
Circle T or F for each of the following statements to indicate whether the statement is true or false,
respectively, and briefly explain why (one or two sentences). Your justification is worth more points
than your true-or-false designation. Careful: Some problems are straightforward, but some are
tricky!
(a) T F Suppose that every operation on a data structure runs in O(1) amortized time. Then
the running time for performing a sequence of n operations on an initially empty data structure is
O(n) in the worst case.
Solution: True:
(b) T F Suppose that a Las Vegas algorithm has expected running time Θ(n) on inputs of size n.
Then there may still be an input on which it always runs in time Ω(n lg n).
Solution: False.
(c) T F If there is a randomized algorithm that solves a decision problem in time t and outputs the
correct answer with probability 0.5, then there is a randomized algo- rithm for the problem that runs
in time Θ(t) and outputs the correct answer with probability at least 0.99.
Solution: False. Every decision problem has an algorithm that produces the cor- rect answer with
probability 0.5 just by flipping a coin to determine the answer.
n
(d) T F Let H : {0, 1} → {1, 2, . . . , k} be a universal family of hash functions, and let
programminghomeworkhelp.com
S ⊆ {0, 1} be a set of |S| = k elements. For h chosen at random from H, let E
be the event that for all y ∈ {1, 2, . . . , k}, the number of elements in S hashed to y is at most 100,
that is, |h (y) ∩S| ≤ 100. Then we have Pr {E } ≥ 3/4. −1−1
Solution: False. |h (y) ∩ S| is likely to be Θ(log k/ log log k) for some y. Only its expectation is
O(1).
(e) T F Let Σ = {a, b, c, . . . , z} be a 26-letter alphabet, and let s ∈ Σ and p ∈ Σ n b e m
strings of length n and m < n respectively. Then there is a Θ(n)-time algorithm to check whether p
is a substring of s.
Solution: True. E.g., using suffix trees.
(f) T F If an iteration of the Ford-Fulkerson algorithm on a network places flow 1 through an edge
(u, v), then in every later iteration, the flow through (u, v) is at least 1.
Solution: False: A later augmenting path may pass through (v, u), causing the flow on (u, v) to be
decreased.
(g) T F There exists a minimization problem such that (i) assuming P /= NP , there is no
polynomial-time 1-approximation algorithm for the problem; and (ii) for any constant ǫ >
0, there is a polynomial-time (1 + ǫ)-approximation algorithm for the problem.
Solution: True. There are NP-hard optimization problems with a PTAS, such as
PARTITION, as we saw in class.
Use the substitution method to show that the recurrence
programminghomeworkhelp.com
T (n) = √
n T (√
n) + n
has solution T (n) = O(n lg lg n).
Solution: First, prove a base case. For 4 ≤ n ≤ 16, let T (n) = O(1) ≤ k for some k > 0. For
some c ≥ k/4, we have that T (n) ≤ cn lg lg n.
Now, prove the inductive case. Assume T (n) ≤ cn lg lg n for some c > 0. Then:
T (n) = √
n T (√
n) + n ≤ √
n c√
n lg lg √
n + n
We now find c > 0 so that
√
n c√
n lg lg √
n + n ≤ cn lg lg n nc(lg lg n − lg 2) + n ≤
cn lg lg n −c lg 2 + 1 ≤ 0 1 ≤ c
Hence, the inductive case holds for any c ≥ 1. Setting c = max{k/4, 1}, we have T (n) ≤
cn lg lg n for all 4 ≤ n.
Problem 3. Updating a Flow Network
Let G = (V, E) be a flow network with source s and sink t, and suppose that each edge e ∈ E has
capacity c(e) = 1. Assume also, for convenience, that |E| = Ω(V ).
(a) Suppose that we implement the Ford-Fulkerson maximum-flow algorithm by using depth-
first search to find augmenting paths in the residual graph. What is the worst- case running
time of this algorithm on G?
Solution: Since the capacity out of the source is |V |− 1, a mincut has value at most
|V |− 1. Thus the running time is O(V E ).
programminghomeworkhelp.com
(b) Suppose that a maximum flow for G has been computed using Ford-Fulkerson, and a new edge
with unit capacity is added to E. Describe how the maximum flow can be efficiently updated.
(Note: It is not the value of the flow that must be updated, but the flow itself.) Analyze your
algorithm.
Solution: Simply run one more BFS to find one augmenting path in the residual flow network.
This costs O(E) time. One path suffices because all edges have capacity 1 so any augmenting
path will have capacity 1 as well.
We could also precompute in O(E) time for each vertex in the graph an edge on a path either to
sink or from source in the residual flow network. (Can’t have both if the flow
is maximum!) Then, given the new edge we can update the flow in O(V ) time.
(c) Suppose that a maximum flow for G has been computed using Ford-Fulkerson, but an edge is
now removed from E. Describe how the maximum flow can be efficiently updated. Analyze your
algorithm.
Solution: In the residual flow network, find a path from sink to source via the edge to be
removed. To do so, find a path from sink to the starting endpoint of the directed edge in the
residual flow network and similarly the second segment of the path. Then diminish the flow by one
unit along the path. Since all edges have capacity 1, this removes the flow from the edge to be
removed. After removing the edge, search for augmenting path in the residual flow network. This
is needed in case the edge was not in the minimum cut hence the flow can be redirected. The total
cost is O(E).
Recall the following problem abstracted from the take-home quiz, which we shall refer to as
Eleanor’s optimization problem. Consider a directed graph G = (V, E) in which every edge e ∈ E
has a length ℓ(e) ∈ Z and a cost c(e) ∈ Z. Given a source s ∈ V , a destination t ∈ V , and a cost x,
programminghomeworkhelp.com
find the shortest path in G from s to t whose total cost is at most x.
We can reformulate Eleanor’s optimization problem as a decision problem. Eleanor’s decision
problem has the same inputs as Eleanor’s optimization problem, as well as a distance d. The problem
is to determine if there exists a path in G from s to t whose total cost is at most x and whose length is
at most d.
(a) Argue that Eleanor’s decision problem has a polynomial-time algorithm if and only if Eleanor’s
optimization problem has a polynomial-time algorithm.
Solution: Reduce decision to optimization: solve optimization, output “YES” iff length of found
path is less than d.
Reduce optimization to decision: Compute sum of all edge lengths which gives dmax.
Recall the NP-complete PARTITION problem: Given an array S[1 . . n] of natural numbers and a
value r ∈N, determine whether there exists a set A ⊆ {1, 2, . . . , n} of indices such that
(b) Prove that the Eleanor’s decision problem is NP-hard. (Hint: Consider the graph il- lustrated
below, where the label of each edge e is “c(e), ℓ(e)”.)
Solution: Label the left-hand vertex in the hint graph as s and the right-hand vertex
t. Run the algo to the decision problem with this graph and x = c and d = c to finish the
reduction. Any s − t path in the graph corresponds to a set A of the indices of Σthose ”widgets”
where the path follows thΣeupper branch. The length of this path is i∈A S[i], while the cost of this
programminghomeworkhelp.com
path is i∈/A S[i]. The decision algo says YES iff there exists a path of both length and cost less
than c, that is, the answer to the PARTITION problem is YES.
If the decision algo returns “NO“ for dmax then there is no solution. Now binary search for the
smallest d in the range [0, dmax] on which the decision algo returns “YES”. Note log dmax is
polynomial in input size.
(c) Argue on the basis of part (b) that Eleanor’s decision problem is NP-complete.
Solution: The witness is the path which can be checked in time linear in the number of its
edges, which is less than |V |. Since the decision problem belongs to NP and is NP-hard, it is
NP-complete.
(d) The solutions to the take-home quiz showed that there is an efficient O(xE +xV lg V ) algorithm
for Eleanor’s optimization problem. Why doesn’t this fact contradict the NP-completeness of
Eleanor’s decision problem?
Solution: An algorithm with runtime O(xE + xV lg V ) has runtime polynomial in the value of
x. In other words, the runtime is actually pseudo-polynomial, rather than truly polynomial. We
showed that Eleanor’s optimization problem was hard by a reduction from Partition, which is
weakly NP-hard. As a result, we have only shown that Eleanor’s Optimization Problem is weakly
NP-hard, and so it’s not a contradiction to have a pseudo-polynomial algorithm.
programminghomeworkhelp.com

More Related Content

Similar to Design and Analysis of Algorithms Assignment Help (20)

NP Complete Problems in Graph Theory
NP Complete Problems in Graph TheoryNP Complete Problems in Graph Theory
NP Complete Problems in Graph Theory
Seshagiri Rao Kornepati
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
P versus NP
P versus NPP versus NP
P versus NP
Rituraj Joshi
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
Programming Homework Help
 
ICPC 2015, Tsukuba : Unofficial Commentary
ICPC 2015, Tsukuba: Unofficial CommentaryICPC 2015, Tsukuba: Unofficial Commentary
ICPC 2015, Tsukuba : Unofficial Commentary
irrrrr
 
Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))
Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))
Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))
leoyang0406
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
Programming Homework Help
 
Ai4 heuristic2
Ai4 heuristic2Ai4 heuristic2
Ai4 heuristic2
Mohammad Faizan
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
Techglyphs
 
Algorithms Design Exam Help
Algorithms Design Exam HelpAlgorithms Design Exam Help
Algorithms Design Exam Help
Programming Exam Help
 
np hard, np complete, polynomial and non polynomial
np hard, np complete, polynomial and non polynomialnp hard, np complete, polynomial and non polynomial
np hard, np complete, polynomial and non polynomial
govindnarayanpatel
 
Fine Grained Complexity
Fine Grained ComplexityFine Grained Complexity
Fine Grained Complexity
AkankshaAgrawal55
 
Randomized algorithms all pairs shortest path
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest path
Mohammad Akbarizadeh
 
09 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 109 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 1
Neeldhara Misra
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
appasami
 
Network Design Assignment Help
Network Design Assignment HelpNetwork Design Assignment Help
Network Design Assignment Help
Computer Network Assignment Help
 
Lower bound theory Np hard & Np completeness
Lower bound theory Np hard & Np completenessLower bound theory Np hard & Np completeness
Lower bound theory Np hard & Np completeness
yvtinsane
 
28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms
28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms
28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms
Andres Mendez-Vazquez
 
AI Lesson 06
AI Lesson 06AI Lesson 06
AI Lesson 06
Assistant Professor
 
FADML 09 PPC NP Completeness (1).pdf
FADML 09 PPC NP Completeness (1).pdfFADML 09 PPC NP Completeness (1).pdf
FADML 09 PPC NP Completeness (1).pdf
Abhishekgarg99271
 
ICPC 2015, Tsukuba : Unofficial Commentary
ICPC 2015, Tsukuba: Unofficial CommentaryICPC 2015, Tsukuba: Unofficial Commentary
ICPC 2015, Tsukuba : Unofficial Commentary
irrrrr
 
Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))
Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))
Dynamic Programming From CS 6515(Fibonacci, LIS, LCS))
leoyang0406
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
Techglyphs
 
np hard, np complete, polynomial and non polynomial
np hard, np complete, polynomial and non polynomialnp hard, np complete, polynomial and non polynomial
np hard, np complete, polynomial and non polynomial
govindnarayanpatel
 
Randomized algorithms all pairs shortest path
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest path
Mohammad Akbarizadeh
 
09 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 109 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 1
Neeldhara Misra
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
appasami
 
Lower bound theory Np hard & Np completeness
Lower bound theory Np hard & Np completenessLower bound theory Np hard & Np completeness
Lower bound theory Np hard & Np completeness
yvtinsane
 
28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms
28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms
28 Dealing with the NP Poblems: Exponential Search and Approximation Algorithms
Andres Mendez-Vazquez
 
FADML 09 PPC NP Completeness (1).pdf
FADML 09 PPC NP Completeness (1).pdfFADML 09 PPC NP Completeness (1).pdf
FADML 09 PPC NP Completeness (1).pdf
Abhishekgarg99271
 

More from Programming Homework Help (20)

Data Structures and Algorithm: Sample Problems with Solution
Data Structures and Algorithm: Sample Problems with SolutionData Structures and Algorithm: Sample Problems with Solution
Data Structures and Algorithm: Sample Problems with Solution
Programming Homework Help
 
Seasonal Decomposition of Time Series Data
Seasonal Decomposition of Time Series DataSeasonal Decomposition of Time Series Data
Seasonal Decomposition of Time Series Data
Programming Homework Help
 
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
Programming Homework Help
 
Exploring Control Flow: Harnessing While Loops in Python
Exploring Control Flow: Harnessing While Loops in PythonExploring Control Flow: Harnessing While Loops in Python
Exploring Control Flow: Harnessing While Loops in Python
Programming Homework Help
 
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
Programming Homework Help
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
Programming Homework Help
 
Python Question - Python Assignment Help
Python Question - Python Assignment HelpPython Question - Python Assignment Help
Python Question - Python Assignment Help
Programming Homework Help
 
Best Algorithms Assignment Help
Best Algorithms Assignment Help Best Algorithms Assignment Help
Best Algorithms Assignment Help
Programming Homework Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
Programming Homework Help
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
Programming Homework Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
Programming Homework Help
 
Algorithms Design Assignment Help
Algorithms Design Assignment HelpAlgorithms Design Assignment Help
Algorithms Design Assignment Help
Programming Homework Help
 
Algorithms Design Homework Help
Algorithms Design Homework HelpAlgorithms Design Homework Help
Algorithms Design Homework Help
Programming Homework Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
Programming Homework Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
Programming Homework Help
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
Programming Homework Help
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
Programming Homework Help
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
Software Construction Assignment Help
Software Construction Assignment HelpSoftware Construction Assignment Help
Software Construction Assignment Help
Programming Homework Help
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
Programming Homework Help
 
Data Structures and Algorithm: Sample Problems with Solution
Data Structures and Algorithm: Sample Problems with SolutionData Structures and Algorithm: Sample Problems with Solution
Data Structures and Algorithm: Sample Problems with Solution
Programming Homework Help
 
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
Solving Haskell Assignment: Engaging Challenges and Solutions for University ...
Programming Homework Help
 
Exploring Control Flow: Harnessing While Loops in Python
Exploring Control Flow: Harnessing While Loops in PythonExploring Control Flow: Harnessing While Loops in Python
Exploring Control Flow: Harnessing While Loops in Python
Programming Homework Help
 
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
Java Assignment Sample: Building Software with Objects, Graphics, Containers,...
Programming Homework Help
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
Programming Homework Help
 
Ad

Recently uploaded (20)

Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive LearningSustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdfGEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptxChalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Himalayan Group of Professional Institutions (HGPI)
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student NewsLDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke WarnerPublishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive LearningSustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdfGEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student NewsLDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke WarnerPublishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
Ad

Design and Analysis of Algorithms Assignment Help

  • 1. For any Assignment related queries, call us at : - +1 678 648 4277 visit : - https://www.programminghomeworkhelp.com/, or Email : - [email protected]
  • 2. Problem 1. True or False. Circle T or F for each of the following statements to indicate whether the statement is true or false, respectively, and briefly explain why (one or two sentences). Your justification is worth more points than your true-or-false designation. Careful: Some problems are straightforward, but some are tricky! (a) T F Suppose that every operation on a data structure runs in O(1) amortized time. Then the running time for performing a sequence of n operations on an initially empty data structure is O(n) in the worst case. Solution: True: (b) T F Suppose that a Las Vegas algorithm has expected running time Θ(n) on inputs of size n. Then there may still be an input on which it always runs in time Ω(n lg n). Solution: False. (c) T F If there is a randomized algorithm that solves a decision problem in time t and outputs the correct answer with probability 0.5, then there is a randomized algo- rithm for the problem that runs in time Θ(t) and outputs the correct answer with probability at least 0.99. Solution: False. Every decision problem has an algorithm that produces the cor- rect answer with probability 0.5 just by flipping a coin to determine the answer. n (d) T F Let H : {0, 1} → {1, 2, . . . , k} be a universal family of hash functions, and let programminghomeworkhelp.com
  • 3. S ⊆ {0, 1} be a set of |S| = k elements. For h chosen at random from H, let E be the event that for all y ∈ {1, 2, . . . , k}, the number of elements in S hashed to y is at most 100, that is, |h (y) ∩S| ≤ 100. Then we have Pr {E } ≥ 3/4. −1−1 Solution: False. |h (y) ∩ S| is likely to be Θ(log k/ log log k) for some y. Only its expectation is O(1). (e) T F Let Σ = {a, b, c, . . . , z} be a 26-letter alphabet, and let s ∈ Σ and p ∈ Σ n b e m strings of length n and m < n respectively. Then there is a Θ(n)-time algorithm to check whether p is a substring of s. Solution: True. E.g., using suffix trees. (f) T F If an iteration of the Ford-Fulkerson algorithm on a network places flow 1 through an edge (u, v), then in every later iteration, the flow through (u, v) is at least 1. Solution: False: A later augmenting path may pass through (v, u), causing the flow on (u, v) to be decreased. (g) T F There exists a minimization problem such that (i) assuming P /= NP , there is no polynomial-time 1-approximation algorithm for the problem; and (ii) for any constant ǫ > 0, there is a polynomial-time (1 + ǫ)-approximation algorithm for the problem. Solution: True. There are NP-hard optimization problems with a PTAS, such as PARTITION, as we saw in class. Use the substitution method to show that the recurrence programminghomeworkhelp.com
  • 4. T (n) = √ n T (√ n) + n has solution T (n) = O(n lg lg n). Solution: First, prove a base case. For 4 ≤ n ≤ 16, let T (n) = O(1) ≤ k for some k > 0. For some c ≥ k/4, we have that T (n) ≤ cn lg lg n. Now, prove the inductive case. Assume T (n) ≤ cn lg lg n for some c > 0. Then: T (n) = √ n T (√ n) + n ≤ √ n c√ n lg lg √ n + n We now find c > 0 so that √ n c√ n lg lg √ n + n ≤ cn lg lg n nc(lg lg n − lg 2) + n ≤ cn lg lg n −c lg 2 + 1 ≤ 0 1 ≤ c Hence, the inductive case holds for any c ≥ 1. Setting c = max{k/4, 1}, we have T (n) ≤ cn lg lg n for all 4 ≤ n. Problem 3. Updating a Flow Network Let G = (V, E) be a flow network with source s and sink t, and suppose that each edge e ∈ E has capacity c(e) = 1. Assume also, for convenience, that |E| = Ω(V ). (a) Suppose that we implement the Ford-Fulkerson maximum-flow algorithm by using depth- first search to find augmenting paths in the residual graph. What is the worst- case running time of this algorithm on G? Solution: Since the capacity out of the source is |V |− 1, a mincut has value at most |V |− 1. Thus the running time is O(V E ). programminghomeworkhelp.com
  • 5. (b) Suppose that a maximum flow for G has been computed using Ford-Fulkerson, and a new edge with unit capacity is added to E. Describe how the maximum flow can be efficiently updated. (Note: It is not the value of the flow that must be updated, but the flow itself.) Analyze your algorithm. Solution: Simply run one more BFS to find one augmenting path in the residual flow network. This costs O(E) time. One path suffices because all edges have capacity 1 so any augmenting path will have capacity 1 as well. We could also precompute in O(E) time for each vertex in the graph an edge on a path either to sink or from source in the residual flow network. (Can’t have both if the flow is maximum!) Then, given the new edge we can update the flow in O(V ) time. (c) Suppose that a maximum flow for G has been computed using Ford-Fulkerson, but an edge is now removed from E. Describe how the maximum flow can be efficiently updated. Analyze your algorithm. Solution: In the residual flow network, find a path from sink to source via the edge to be removed. To do so, find a path from sink to the starting endpoint of the directed edge in the residual flow network and similarly the second segment of the path. Then diminish the flow by one unit along the path. Since all edges have capacity 1, this removes the flow from the edge to be removed. After removing the edge, search for augmenting path in the residual flow network. This is needed in case the edge was not in the minimum cut hence the flow can be redirected. The total cost is O(E). Recall the following problem abstracted from the take-home quiz, which we shall refer to as Eleanor’s optimization problem. Consider a directed graph G = (V, E) in which every edge e ∈ E has a length ℓ(e) ∈ Z and a cost c(e) ∈ Z. Given a source s ∈ V , a destination t ∈ V , and a cost x, programminghomeworkhelp.com
  • 6. find the shortest path in G from s to t whose total cost is at most x. We can reformulate Eleanor’s optimization problem as a decision problem. Eleanor’s decision problem has the same inputs as Eleanor’s optimization problem, as well as a distance d. The problem is to determine if there exists a path in G from s to t whose total cost is at most x and whose length is at most d. (a) Argue that Eleanor’s decision problem has a polynomial-time algorithm if and only if Eleanor’s optimization problem has a polynomial-time algorithm. Solution: Reduce decision to optimization: solve optimization, output “YES” iff length of found path is less than d. Reduce optimization to decision: Compute sum of all edge lengths which gives dmax. Recall the NP-complete PARTITION problem: Given an array S[1 . . n] of natural numbers and a value r ∈N, determine whether there exists a set A ⊆ {1, 2, . . . , n} of indices such that (b) Prove that the Eleanor’s decision problem is NP-hard. (Hint: Consider the graph il- lustrated below, where the label of each edge e is “c(e), ℓ(e)”.) Solution: Label the left-hand vertex in the hint graph as s and the right-hand vertex t. Run the algo to the decision problem with this graph and x = c and d = c to finish the reduction. Any s − t path in the graph corresponds to a set A of the indices of Σthose ”widgets” where the path follows thΣeupper branch. The length of this path is i∈A S[i], while the cost of this programminghomeworkhelp.com
  • 7. path is i∈/A S[i]. The decision algo says YES iff there exists a path of both length and cost less than c, that is, the answer to the PARTITION problem is YES. If the decision algo returns “NO“ for dmax then there is no solution. Now binary search for the smallest d in the range [0, dmax] on which the decision algo returns “YES”. Note log dmax is polynomial in input size. (c) Argue on the basis of part (b) that Eleanor’s decision problem is NP-complete. Solution: The witness is the path which can be checked in time linear in the number of its edges, which is less than |V |. Since the decision problem belongs to NP and is NP-hard, it is NP-complete. (d) The solutions to the take-home quiz showed that there is an efficient O(xE +xV lg V ) algorithm for Eleanor’s optimization problem. Why doesn’t this fact contradict the NP-completeness of Eleanor’s decision problem? Solution: An algorithm with runtime O(xE + xV lg V ) has runtime polynomial in the value of x. In other words, the runtime is actually pseudo-polynomial, rather than truly polynomial. We showed that Eleanor’s optimization problem was hard by a reduction from Partition, which is weakly NP-hard. As a result, we have only shown that Eleanor’s Optimization Problem is weakly NP-hard, and so it’s not a contradiction to have a pseudo-polynomial algorithm. programminghomeworkhelp.com